<span style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; ">在nginx中设置:</span><br style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; word-wrap: break-word; " /><span style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; ">proxy_set_header Host $host;</span><br style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; word-wrap: break-word; " /><span style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; ">proxy_set_header X-Real-IP $remote_addr;</span><br style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; word-wrap: break-word; " /><span style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; ">proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</span><br style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; word-wrap: break-word; " /><span style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; ">后端程序可以从Server变量HTTP_X_REAL_<wbr>IP和HTTP_X_FORWARDED_<wbr>FOR中获取用户的ip地址。</wbr></wbr></span><br style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; word-wrap: break-word; " /><span style="line-height: 21px; color: rgb(68, 68, 68); font-size: 14px; font-family: Tahoma, 'Microsoft Yahei', Simsun; ">HTTP_X_REAL_<wbr>IP的值是nginx得到的用户REMOTE_ADDR</wbr></span>