nginx配置說明
阿新 • • 發佈:2020-07-16
worker_processes 1;#==工作程序數,一般設定為cpu核心數 events { worker_connections 1024; #==最大連線數,一般設定為cpu*2048 } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #==客戶端連結超時時間 upstream MyServer { server 127.0.0.1:9001; server127.0.0.1:9002; server 127.0.0.1:9003; } upstream host1 { server 127.0.0.1:9001; } upstream host2 { server 127.0.0.1:9002; } upstream default { server 127.0.0.1:9003; } map $COOKIE_version $group { ~*v1$ host1; ~*v2$ host2; default default; } server { listen99; #站點監聽埠 server_name www.nginxtest.com; #服務啟動後直接站點訪問域名 charset utf-8; #編碼格式,避免url引數亂碼 location / { #proxy_pass http://MyServer; #對映到多個站點 proxy_pass http://$group; #根據COOKIE中version的值做對應的站點對映 } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }