'Nginx'에 해당되는 글 1건

[Nginx] config 정리

Nginx 2022. 7. 26. 16:10

경로

/etc/nginx/nginx.conf

user  nginx;
worker_processes  10;


error_log  /webserver/nginx/logs/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /var/log/nginx/access.log  main;

    server_tokens off;
    sendfile        on;
    keepalive_timeout  1200;

#    large_client_header_buffers 4 16k;
    client_max_body_size 200M;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
    fastcgi_send_timeout 600;
    fastcgi_read_timeout 600;


    charset utf-8;

    include /etc/nginx/conf.d/*.conf;
}
  • user: nginx의 worker process가 실행되는 user권한. 공백을 구분자로 두번째 값을 써줄 수 있는데, 이는 group을 의미하며, 생략시 user와 같은 그룹을 사용한다.(기본값 nobody)
  • worker_processes: worker process의 수를 의미. 최적값은 하드웨어의 코어수, 하드드라이브 이용률 및 로드패턴 등과 복잡하게 얽혀 있어서 일반적으로 코어수와 동일하게 맞추는것을 권장한다.(기본값 1)
  • error_log: 로그파일 경로와 남기고자 하는 심각도 레벨. (기본값 logs/error.log) 레벨은 다음 값 중 하나이다.(심각도 오름차순)(기본값 error)
    debug, info, notice, warn, error, crit, alert, or emerg
  • pid: nginx main process(=master process)의 pid 저장 파일경로(기본값 logs/nginx.pid)
  • events.worker_connections: 한개의 worker process가 동시에 오픈할 수 있는 최대 연결 갯수. client 와의 연결만 포함하는게 아니고, 모든 connection을 포함한다. (주의)worker_rlimit_nofile 값을 초과해서 세팅하면, worker_rlimit_nofile 값이 우선시된다.(기본값 512)
  • http.include: http 블록에 가져올 context 파일 경로.(여기서는 mimetype 정의 파일 - mimetype 목록과 파일 확장명)
  • http.default_type: mimetype 중에 기본값으로 사용할 값(여기서는 application/octet-stream)
  • http.log_format: 로그포멧 이름과 형식 지정. 가상호스트 설정시 로그파일 뒤에 로그포멧 이름을 지정하면 해당 포멧대로 로그가 쌓인다.(여기서는 main이 로그포멧 이름)
  • http.server_tokens: off로 설정시 response 의 Server 헤더값에서 nginx 버전을 지워준다.(보안상 이점)
  • http.sendfile: on으로 설정시 read/write시 하드디스크 io를 일으키지 않고 커널 내부에서 파일을 복사하여 속도 향상
  • http.keepalive_timeout: 서버에 접속시 클라이언트와 커넥션을 열린채로 유지하는 시간.(0으로 잡으면 keepalive 비활성)
  • http.client_max_body_size: 파일 업로드 제한용량. 파일 업로드시 http 응답코드 413 (equest Entity Too Large)인 경우 이를 설정하면 해결됨.
  • http.proxy_connect_timeout: 프록시 서버와 연결(establishing)시 timeout. 모든 서버에 대해 적용됨. server나 location 컨텍스트에서 재정의 가능
  • http.proxy_send_timeout: 프록시 서버에 요청시 timeout. 모든 서버에 대해 적용됨. server나 location 컨텍스트에서 재정의 가능
  • http.proxy_read_timeout: 프록시 서버에 요청 후 응답을 기다리는 timeout. 모든 서버에 대해 적용됨. server나 location 컨텍스트에서 재정의 가능
  • http.send_timeout: 클라이언트에 응답을 보내는 timeout.
  • http.fastcgi_send_timeout: fastcgi 프로토콜로 프록시 서버에 요청시 timeout.
  • http.fastcgi_read_timeout: fastcgi 프로토콜로 프록시 서버에 요청 후 응답을 기다리는 timeout.
  • http.charset: 문자셋 설정

 

 

 

 


https://gist.github.com/goodGid/19aceb989a86adbb4560e976cf437453

 

Nginx Conf

Nginx Conf. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

http://nginx.org/en/docs/ngx_core_module.html

 

Core functionality

Core functionality Example Configuration user www www; worker_processes 2; error_log /var/log/nginx-error.log info; events { use kqueue; worker_connections 2048; } ... Directives Syntax: accept_mutex on | off; Default: accept_mutex off; Context: events If

nginx.org

https://www.nginx.com/nginx-wiki/build/dirhtml/start/topics/examples/full/

 

Full Example Configuration | NGINX

Full Example Configuration nginx.conf user www www; ## Default: nobody worker_processes 5; ## Default: 1 error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; ## Default: 1024 } http { include conf/mime.

www.nginx.com

 

블로그 이미지

망원동똑똑이

프로그래밍 지식을 자유롭게 모아두는 곳입니다.

,