upstream tornado_servers { least_conn; # 使用最少连接数算法 server 192.168.31.158:8888 weight=5; server localhost:8888 weight=3; } server { listen 80; server_name 192.168.62.132; location / { proxy_pass http://tornado_servers; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } location /nginx_status { stub_status on; access_log off; allow 192.168.62.0/24; # 允许访问的IP地址,根据需要调整 deny all; # 禁止其他IP地址访问 } }
upstream tornado_servers { ip_hash; # 使用IP哈希算法 server 192.168.31.158:8888; server localhost:8888; } server { listen 80; server_name 192.168.62.132; location / { proxy_pass http://tornado_servers; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } location /nginx_status { stub_status on; access_log off; allow 192.168.62.0/24; # 允许访问的IP地址,根据需要调整 deny all; # 禁止其他IP地址访问 } }
标签:负载,set,header,192.168,server,nginx,proxy,均衡,servers From: https://www.cnblogs.com/dj258/p/18246754