http{...set_real_ip_from0.0.0.0/0;# 允许所有IP地址的代理 real_ip_headerX-Forwarded-For;real_ip_recursive on;...server{...location/{...# 如果需要日志中记录真实IPlog_format custom'$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''...
首先点击宝塔应用商店,找到nginx,点击右边的设置,在配置修改中,找到http模块中的include luawaf.conf;,在下面添加如下两段代码,重载nginx 12 set_real_ip_from 0.0.0.0/0;real_ip_header X-Forwarded-For; 同时在/www/server/panel/vhost/nginx/proxy/你的网站这里路径下面能找到一个配置文件,在location /加上 ...
set_real_ip_from:真实服务器上一级代理的IP地址或者IP段,可以写多行 real_ip_header:从哪个header头检索出要的IP地址 real_ip_recursive:递归排除IP地址,ip串从右到左开始排除set_real_ip_from里面出现的IP,如果出现了未出现这些ip段的IP,那么这个IP将被认为是用户的IP。例如我这边的例子,真实服务器获取到的...
当real_ip_recursive 指令值为 off,nginx 从获取到 IP 值中从右往左(也即从后往前)的顺序,以最后一个 IP 值作为客户端的真实 IP ,此时不会排除授信 IP; 当real_ip_recursive 指令值为 on,nginx 从获取到 IP 值中从右往左(也即从后往前)的顺序,排除 set_real_ip_from 指令指定的授信 IP,以最后一个...
real_ip_recursive的效果看明白了吧. set_real_ip_from:真实服务器上一级代理的IP地址或者IP段,可以写多行 real_ip_header:从哪个header头检索出要的IP地址 real_ip_recursive:递归排除IP地址,ip串从右到左开始排除set_real_ip_from里面出现的IP,如果出现了未出现这些ip段的IP,那么这个IP将被认为是用户的IP...
real_ip_recursive: on 表示递归排除IP地址,IP串从右往左排除set_real_ip_from 中出现的IP。如果IP串有个IP并不在其中,那么这个IP就是用户IP. 例如:真实服务器获取的IP串如下 当real_ip_recursive: on, xx3.xx.xx.xx xx2.xx.xx.xx xx1.xx.xx.0 都在set_rel_ip_from列表中,递归到xx4.xx....
首先,real_ip_header 指定一个http首部名称,默认是X-Real-Ip,假设用默认值的话,nginx在接收到报文后,会查看http首部X-Real-Ip。 (1)如果有1个IP,它会去核对,发送方的ip是否在set_real_ip_from指定的信任ip列表中。如果是被信任的,它会去认为这个X-Real-Ip中的IP值是前代理告诉自己的,用户的真实IP值,于...
set_real_ip_from 0.0 . 0.0 / 0 ; real_ip_header X-Forwarded-For; real_ip_recursive on; } } 3、配置完成后A、使用nginx检查配置文件是否正确。B、重启nginx服务(Restart)4、测试1、配置前[root @xxx nginx]# tailf there.pier39.cn | grep -v HEAD 100.97 . 15.4 - - [ 22 /Feb/...
set_real_ip_from 192.168.180.0/24; set_real_ip_from 192.168.181.0/24; real_ip_header X-Forwarded-For; real_ip_recursive on; } } 如果服务器获取的IP地址如下: 192.168.180.4 192.168.181.30 118.242.26.94 在real_ip_recursive on的情况下,192.168.180.4和192.168.181.30这两个IP地址都在set_real_ip...
set_real_ip_from 192.168.56.88; #real_ip_header X-Forwarded-For; fastcgi_pass unix:/var/sock/php-fpm/www.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $request_filename; include fastcgi_params; } 暂时先不用打开 real_ip_header 的注释,默认情况下使用的就是 X-Real-IP 。我...