https://juejin.cn/post/6844903953776410638
upstream demoapi { ip_hash; server 172.20.0.100:20001; server 172.20.0.101:20001; } server { listen 10080; server_name localhost;
location / { proxy_connect_timeout 180; proxy_send_timeout 180; proxy_read_timeout 180; # 获取真实客户端IP写入到请求头x-Real-IP proxy_set_header X-Real-IP $remote_addr; # proxy_set_header Host $host; # 获取代理端口 proxy_set_header Host $host:$server_port; proxy_redirect off; proxy_pass http://demoapi; proxy_http_version 1.1; } }
|