默認在 /etc/nginx 目錄下node
3504 root 20 0 141M 7196 5552 S 0.0 0.4 0:00.03 nginx: master process nginx 6154 www-data 20 0 141M 3628 1828 S 0.0 0.2 0:00.00 `- nginx: worker process 6152 www-data 20 0 141M 3628 1828 S 0.0 0.2 0:00.00 `- nginx: worker process
;
結尾{}
包圍events { worker_connections 768; # multi_accept on; } http { server { root /opt; location /test { root /etc; } location /tmp/ { root /home; } } }
上面的這個配置文件:
當 path == test
的時候, eg: http://127.0.0.1/test/hello.txt 則 nginx 會 open /etc/test/hello.txt
nginx
path == /tmp
, eg: http://127.0.0.1/tmp/hello.txt 則 nginx open /home/tmp/hello.txt
bash
path != test and path != tmp
eg:http://127.0.0.1/hello/hello.txt 則 nginx open /opt/htllo/hello.txtapp
例如:tcp
location / { # empty }
location /{ proxy_pass http://google.com; }
location ~\.(pdf|doc) { root /opt; }
➜ nginx cat /var/run/nginx.pid 3504
user www-data; worker_processes 1; pid /run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }