### nginx configure technical guide
drwxr-xr-x 2 root root 4096 Sep 18 05:52 conf.d
drwxr-xr-x 2 root root 4096 Sep 11 19:46 default.d
-rw-r--r-- 1 root root 1077 Sep 11 19:46 fastcgi.conf
-rw-r--r-- 1 root root 1077 Sep 11 19:46 fastcgi.conf.default
-rw-r--r-- 1 root root 1007 Sep 11 19:46 fastcgi_params
-rw-r--r-- 1 root root 1007 Sep 11 19:46 fastcgi_params.default
-rw-r--r-- 1 root root 2837 Sep 11 19:46 koi-utf
-rw-r--r-- 1 root root 2223 Sep 11 19:46 koi-win
-rw-r--r-- 1 root root 3957 Sep 11 19:46 mime.types
-rw-r--r-- 1 root root 3957 Sep 11 19:46 mime.types.default
-rw-r--r-- 1 root root 3734 Sep 11 19:46 nginx.conf
-rw-r--r-- 1 root root 2656 Sep 11 19:46 nginx.conf.default
-rw-r--r-- 1 root root 636 Sep 11 19:46 scgi_params
-rw-r--r-- 1 root root 636 Sep 11 19:46 scgi_params.default
-rw-r--r-- 1 root root 664 Sep 11 19:46 uwsgi_params
-rw-r--r-- 1 root root 664 Sep 11 19:46 uwsgi_params.default
-rw-r--r-- 1 root root 3610 Sep 11 19:46 win-utf
- nginx.conf 분석
http://nginx.org/en/docs/ngx_core_module.html
user nginx;
ㄴ http://nginx.org/en/docs/ngx_core_module.html#user
ㄴ Syntax: user user [group];
ㄴ nginx 가 실행되는 사용자 및 그룹에 대한 설정입니다. 그룹이 설정되어 있지 않는경우 user 와 동일한 그룹으로 실행이 됩니다.
worker_processes auto;
ㄴ http://nginx.org/en/docs/ngx_core_module.html#worker_processes
ㄴ Syntax: worker_processes number | auto;
ㄴ nginx 가 실행될때에 동시에 올라가는 프로세스 갯수 설정 입니다. auto 인경우 nginx 가 자동으로 하드웨어 리소스를 감지한후 적절한값의 Process 를 running 합니다.
error_log /var/log/nginx/error.log;
ㄴ http://nginx.org/en/docs/ngx_core_module.html#error_log
ㄴ Syntax: error_log file [level];
ㄴ 에러 로그에 대한 설정 내용입니다. 첫번째 변수는 경로를 설정하며, 두번째 변수는 로깅의 수준을 설정합니다. 두번째 변수가 설정되어 있지않으면, emerg 의 수준의 로깅을 기록합니다.
pid /var/run/nginx.pid;
ㄴ http://nginx.org/en/docs/ngx_core_module.html#pid
ㄴ Default: pid nginx.pid;
ㄴ 주 프로세스의 프로세스 ID 값을 정의 합니다.
include /usr/share/nginx/modules/*.conf;
ㄴ Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
ㄴ nginx 에서 사용할 동적 모듈에 대한 설정파일 입니다.
events {
ㄴ http://nginx.org/en/docs/ngx_core_module.html#events
ㄴ connection 에 대한 설정을 하는 구문을 정의합니다.
worker_connections 1024;
}
ㄴ http://nginx.org/en/docs/ngx_core_module.html#worker_connections
ㄴ Syntax: worker_connections number;
ㄴ worker_process 의 최대 동시 접속수를 설정합니다. 해당 설정은 Client 뿐만 아니라 Proxy 와의 연결도 포함됩니다.
ㄴ OS 의 최대 파일 연결수 보다 더 많은 수치의 값을 설정할수 없습니다. worker_rlimit_nofile 의 변경을 통해서 수정이 가능합니다.
http {
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#http
ㄴ http 에 대한 설정을 하는 구문을 정의합니다.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
ㄴ http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
ㄴ Syntax: log_format name [escape=default|json] string ...;
ㄴ 로그형식을 지정 합니다.
access_log /var/log/nginx/access.log main;
ㄴ http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
ㄴ Syntax: access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]]; / access_log off;
ㄴ buffer 된 log write 및 path, format 을 정의 합니다. buffer또는 gzip 을 사용하게되면 log 가 buffer 됩니다.
sendfile on;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#sendfile
ㄴ Syntax: sendfile on | off;
ㄴ sendfile() 의 사용에 대한 활성화 및 비활성화를 정의 합니다.
tcp_nopush on;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#tcp_nopush
ㄴ Syntax: tcp_nopush on | off;
ㄴ FreeBSD 의 TCP_NOPUSH socket option 혹은 Linux TCP_CORK socket option 을 사용하거나 사용하지 않거나의 여부를 정의 합니다. sendfile() 이 사용될때만 사용이 가능합니다.
tcp_nodelay on;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#tcp_nodelay
ㄴ Syntax: tcp_nodelay on | off;
ㄴ TCP_NODELAY option 의 사용여부를 설정합니다. keepalive 설정되어있을 경우에만 활성화 됩니다.
keepalive_timeout 65;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#keepalive_timeout
ㄴ Syntax: keepalive_timeout timeout [header_timeout];
ㄴ 서버에서 연결유지를 위한 대기시간을 설정합니다. 0 은 keep-alive 를 disable 하는것과 동일합니다.
types_hash_max_size 2048;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#types_hash_max_size
ㄴ Syntax: types_hash_max_size size;
ㄴ Hash table 의 최대 크기를 설정합니다.
ㄴ http://nginx.org/en/docs/hash.html 에 Hash table 에 대한 설명이 나와 있습니다.
include /etc/nginx/mime.types;
ㄴ mime.types 값에 대한 설정을 설정파일에 inclede 합니다.
default_type application/octet-stream;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#default_type
ㄴ Syntax: default_type mime-type;
ㄴ respons 의 default mime.type 값을 정의 합니다.
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
ㄴ /etc/nginx/conf.d/ 디렉토리의 conf 확장자의 설정파일을 include 합니다.
index index.html index.htm;
ㄴ http://nginx.org/en/docs/http/ngx_http_index_module.html#index
ㄴ Syntax: index file ...;
ㄴ index 파일을 정의 합니다. 파일은 지정된 순서로 검색 됩니다.
server {
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#server
ㄴ 가상 서버 구간을 설정 합니다. IP 기반의 설정과 도메인 기반의 설정 두가지가 가능합니다.
listen 80 default_server;
listen [::]:80 default_server;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#listen
ㄴ Syntax: listen address[:port] [default_server] [ssl] [http2 | spdy] [proxy_protocol] [setfib=number] [fastopen=number] [backlog=number] [rcvbuf=size] [sndbuf=size] [accept_filter=filter] [deferred] [bind] [ipv6only=on|off] [reuseport] [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
listen port [default_server] [ssl] [http2 | spdy] [proxy_protocol] [setfib=number] [fastopen=number] [backlog=number] [rcvbuf=size] [sndbuf=size] [accept_filter=filter] [deferred] [bind] [ipv6only=on|off] [reuseport] [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
listen unix:path [default_server] [ssl] [http2 | spdy] [proxy_protocol] [backlog=number] [rcvbuf=size] [sndbuf=size] [accept_filter=filter] [deferred] [bind] [so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]];
ㄴ IP 주소 혹은 포트, 서비가 요청을 수락한 UNIX Socket 의 경로를 설정합니다. 주소와 포트를 동시에 사용가능하며, 주소, 포트를 각각 독립적으로 사용 가능합니다. 주소는 도메인일수도 있습니다.
ㄴ Default_server 설정값이 있으면 설정된 값이 기본 설정입니다. 해당 값이 없는경우 address:port 로 되어있는 첫번째 설정이 Default 설정으로 사용됩니다.
server_name localhost;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#server_name
ㄴ Syntax: server_name name ...;
ㄴ 가상서버의 name 을 정의 합니다.
root /usr/share/nginx/html;
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#root
ㄴ Syntax: root path;
ㄴ request 에 대한 root directory 를 설정합니다.
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
ㄴ /etc/nginx/default/ 디렉토리의 conf 확장자의 설정파일을 include 합니다.
location / {
}
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#location
ㄴ Syntax: location [ = | ~ | ~* | ^~ ] uri { ... } / location @name { ... }
ㄴ 요청 URI 에 따른 구성을 설정 합니다.
# redirect server error pages to the static page /40x.html
#
error_page 404 /404.html;
location = /40x.html {
}
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
ㄴ Syntax: error_page code ... [=[response]] uri;
ㄴ 지정된 오류에 대해 표시할 URI 를 정의 합니다. URI 값은 변수로 지정 가능합니다.
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
ㄴ http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
ㄴ Syntax: error_page code ... [=[response]] uri;
ㄴ 지정된 오류에 대해 표시할 URI 를 정의 합니다. URI 값은 변수로 지정 가능합니다.
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
'Web Server > NginX' 카테고리의 다른 글
NginX 설치하기 (0) | 2017.10.31 |
---|