#Nginx所用使用者和組,window下不指定 #user niumd niumd; #工作的子進程數量(通常等於CPU數量或者2倍於CPU) worker_processes 8; #錯誤記錄檔存放路徑 #error_log logs/error.log; #error_log logs/error.log notice; error_log logs/error.log info; #指定pid存放檔案 pid logs/nginx.pid; events { #使用網路IO模型linux建議epoll,FreeBSD建議-www.2cto.com-採用kqueue,window下不指定。 #use epoll; #允許最大串連數 worker_connections 2048; } 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"'; #access_log off; access_log logs/access.log; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; client_header_buffer_size 1k; large_client_header_buffers 4 4k; sendfile on; tcp_nopush on; tcp_nodelay on; #keepalive_timeout 75 20; #include gzip.conf; upstream localhost { #根據ip計算將請求分配各那個後端tomcat,許多人誤認為可以解決session問題,其實並不能。 #同一機器在多網情況下,路由切換,ip可能不同 #ip_hash; server localhost:8080; #server localhost:18080; } server { listen 80; server_name localhost; location / { proxy_pass http://localhost; } } } 作者 zhyxfancy