1. Directory Listing

웹서버 운영 시 보안을 위해 설정하는 기본적인 것 옵션 중 하나가 Directory Listing 이다.

index 파일이 없을 경우 호출된 경로에 있는 파일 List를 보여주는 Directory Listing을 막기 위해서는

nginx.conf 에 아래와 같이 설정하면 된다. 참고로, Default 값은 OFF 이다.

 

location / {
    autoindex  off;
}

Directory Listing 기능을 제공하는 것은 ngx_http_autoindex_module로,

해당 기능이 필요하지 않다면 아래와 같이 nginx 컴파일 시 해당 모듈을 제외하고 컴파일 할 수 있다.

$ ./configure --without-http_autoindex_module --without-http_ssi_module
$ make
$ make install

 

2. 서버 정보 보안

Nginx 버전 정보를 Response Header에서 숨기고 싶다면, nginx.conf에 아래와 같이 설정하면 된다.

server_tokens off;

또는, 컴파일 전에 아래 파일의 웹서버 명(AAAAAAAA, BBBBBBBB 부분)을 변경하면 해당 이름이 서버 정보로 나타나게 된다.

파일 경로 : src/http/ngx_http_header_filter_module.c

static char ngx_http_server_string[] = "Server: AAAAAAAAAA" CRLF;
static char ngx_http_server_full_string[] = "Server: BBBBBBBBBB "  CRLF;