nginx默認的配置文件詳解
阿新 • • 發佈:2018-07-15
http sendfile 數量 sta auto 超時 module info tin
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
# 運行用戶,默認是nginx
worker_processes auto;
# nginx進程數,一般設置為和cpu核數一樣
error_log /var/log/nginx/error.log;
# 全局錯誤日誌路徑
pid /run/nginx.pid;
# 進程pid路徑
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
# 負載動態模塊
include /usr/share/nginx/modules/*.conf;
events {
# 工作模式與連接數上限
worker_connections 1024;
# 單個進程的最大連接數
}
http {
# 設置http服務器
log_format main ‘$http_host $server_addr $remote_addr [$time_local] "$request" $status $request_body $body_bytes_sent "$http_referer" "$http_user_agent" $request_time $upstream_response_time‘;
# 設置日誌的格式
access_log /var/log/nginx/access.log main;
# 訪問日誌的路徑
sendfile on;
# 開啟高效傳輸模式
tcp_nopush on;
# 激活tcp_nopush參數可以允許把http response header和文件的開始放在一個文件裏發布,作用是減少網絡報文段的數量
tcp_nodelay on;
# 激活tcp_nodelay,內核會等待將更多的字節組成一個數據包,從而提高I/O性能
keepalive_timeout 65;
# 長連接超時時間,單位是秒
types_hash_max_size 2048;
# 為了快速處理靜態數據集,例如服務器名稱, 映射指令的值,MIME類型,請求頭字符串的名稱,nginx使用哈希表
include /etc/nginx/mime.types;
# 文件擴展名與類型映射表
default_type application/octet-stream;
# 默認文件類型
# 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;
server {
# 基於域名的虛擬主機
listen 80 default_server;
# 監聽端口
listen [::]:80 default_server;
server_name _;
# 域名
root /usr/share/nginx/html;
# 站點根目錄,即網站程序存放目錄
# Load configuration files for the default server block.
# 默認服務器塊的加載配置文件
include /etc/nginx/default.d/*.conf;
location / {
# 對“/”啟用反向代理
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
nginx默認的配置文件詳解