nginx反向代理获取用户真实ip
2017年3月5日 3 条评论
nginx做反向代理时,默认的配置后端获取到的ip都是来自于nginx,那么如何转发用户的真实IP到后端程序呢? 当前端使用nginx代理,后端使用php-fpm时,如果还是使用$_SERVER['REMOTE_ADDR'],那么php程序获取到的是nginx的ip地址,而不是用户的真实ip。 upstream www.redis.com.cn { ip_hash; server serving-server1.com:80; server serving-server2.com:80; } server { listen www.redis.com.cn:80; server_name www.redis.com.cn;location / { proxy_pas...
近期评论