K7

K7Blog

须知少年凌云志 曾许人间第一流.
proton
telegram

使用宝塔NGINX反向代理后,后端获取前端访客真实IP方法

A:前端物理机

给网站配置文件添加:

#向后端传递真实IP
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_set_header HTTP_X_FORWARDED_FOR $remote_addr;
#向后端传递真实IP

B:后端物理机(实际生产环境)

给网站配置文件添加:

#获取前端真实IP
set_real_ip_from XXX.XXX.XXX.XXX; (这里填写你前端CDN的真实IP)
#获取前端真实IP
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.