在nginx代理服务器的location中增加以下配置
1 2 3 4 |
proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; <wbr /> |
如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
upstream www.test.cn { ip_hash; server 10.0.0.7:80; server 10.0.0.8:80; } server { listen 80; server_name www.test.cn; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://www.test.cn; } } |