全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1659|回复: 11

套cf的话,怎么获取用户的真实ip呢?

[复制链接]
发表于 2023-1-5 00:12:28 | 显示全部楼层 |阅读模式
我后端获取的ip都是cf的ip。
发表于 2023-1-5 00:17:42 | 显示全部楼层
  1.     set_real_ip_from 0.0.0.0/0;
  2.     set_real_ip_from ::/0;
  3.     real_ip_header X-Forwarded-For;
复制代码


丢在伪静态里
发表于 2023-1-5 00:17:31 来自手机 | 显示全部楼层
请求头里有真实IP
发表于 2023-1-5 00:30:18 | 显示全部楼层
cf-connecting-ip就是真实ip
https://developers.cloudflare.com/fundamentals/get-started/reference/http-request-headers/
发表于 2023-1-5 00:54:12 | 显示全部楼层
发表于 2023-1-5 02:24:05 | 显示全部楼层
涨姿势,来学习下~
 楼主| 发表于 2023-1-5 09:43:58 | 显示全部楼层
lonefly 发表于 2023-1-5 00:54
https://www.yunloc.com/647.html

方法2,我把代码添加到我/etc/nginx/nginx.conf 的http里面,重启出错,不能添加这个代码呢。
发表于 2023-1-5 10:16:25 | 显示全部楼层
斌斌 发表于 2023-1-5 09:43
方法2,我把代码添加到我/etc/nginx/nginx.conf 的http里面,重启出错,不能添加这个代码呢。 ...

站点日志后面加上access

access_log /www/wwwlogs/yunloc.com.log access;
 楼主| 发表于 2023-1-5 10:34:43 | 显示全部楼层
lonefly 发表于 2023-1-5 10:16
站点日志后面加上access

access_log /www/wwwlogs/yunloc.com.log access;

不是这个问题呢。是加了方法二的东西,重启nginx直接出错。
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

root@HZ1 ~ # systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2023-01-05 10:32:36 CST; 6s ago
       Docs: man:nginx(8)
    Process: 166235 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited,>        CPU: 5ms

Jan 05 10:32:36 HZ1 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jan 05 10:32:36 HZ1 nginx[166235]: nginx: [emerg] pcre_compile() failed: unrecognized character after>Jan 05 10:32:36 HZ1 nginx[166235]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jan 05 10:32:36 HZ1 systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jan 05 10:32:36 HZ1 systemd[1]: nginx.service: Failed with result 'exit-code'.
Jan 05 10:32:36 HZ1 systemd[1]: Failed to start A high performance web server and a reverse proxy ser>
发表于 2023-1-18 21:01:45 | 显示全部楼层
请问大佬们,反代CF后,怎样让CF识别出真实用户的IP,而不是反代服务器的,现在WAF的事件里面,全是反代服务器的IP
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-21 15:27 , Processed in 0.085440 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表