Ric*_*ols 2 nginx proxy load-balancing sticky-sessions
nginx 是否将直接客户端的 IP 用于 ip_hash,或者它还观察 X-forwarded-for HTTP 标头以用作 ip_hash 的 IP 地址?
例如,在某些使用共享代理服务器的客户端访问带有 ip_hash 的 nginx 负载均衡器的情况下,所有这些客户端都会散列到同一个节点吗?
或者 nginx 会使用 X-forwarded-for 标头将它们散列到不同的节点吗?
小智 10
虽然这个问题很老而且答案是正确的,但经过一些挖掘以解决我自己的负载平衡问题后,我发现有一个更新的选项可以使客户端 ip 基于 X-Forwarded-For 或 X-Real-IP 和当与 ip_hash 指令结合使用时,它使用用户的实际 IP 作为哈希值来适当地平衡负载。
http://nginx.org/en/docs/http/ngx_http_realip_module.html
set_real_ip_from 127.0.0.1; # nginx and varnish on other ports
real_ip_header X-Real-IP; # or X-Forwarded-For
# real_ip_recursive on; # doesn't work on nginx 1.0
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9008 次 |
最近记录: |