全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
12
返回列表 发新帖

请教各位大佬,开启cloudflare缓存后如何查看访问统计呢?

[复制链接]
 楼主| 发表于 2021-3-18 17:47:09 | 显示全部楼层

貌似看不到访问详情,是不是要专业版才行?
发表于 2021-3-18 20:44:23 | 显示全部楼层
如果是用Apache2的话,可以这样:

假设新建一个真实IP的配置文件,名为realips.conf,放在/etc/apache2/conf-available目录下(如果是debian/ubuntu系的包安装,默认是这个地址,如果是自己编译的或centos系的,那么位置会有变化)。

用用户而非管理员身份运行如下代码(如果是管理员root身份则不用sudo了)

  1. sudo bash -c 'echo \
  2. "RemoteIPHeader CF-Connecting-IP
  3. RemoteIPTrustedProxy 173.245.48.0/20
  4. RemoteIPTrustedProxy 103.21.244.0/22
  5. RemoteIPTrustedProxy 103.22.200.0/22
  6. RemoteIPTrustedProxy 103.31.4.0/22
  7. RemoteIPTrustedProxy 141.101.64.0/18
  8. RemoteIPTrustedProxy 108.162.192.0/18
  9. RemoteIPTrustedProxy 190.93.240.0/20
  10. RemoteIPTrustedProxy 188.114.96.0/20
  11. RemoteIPTrustedProxy 197.234.240.0/22
  12. RemoteIPTrustedProxy 198.41.128.0/17
  13. RemoteIPTrustedProxy 162.158.0.0/15
  14. RemoteIPTrustedProxy 104.16.0.0/12
  15. RemoteIPTrustedProxy 172.64.0.0/13
  16. RemoteIPTrustedProxy 131.0.72.0/22
  17. RemoteIPTrustedProxy 2400:cb00::/32
  18. RemoteIPTrustedProxy 2606:4700::/32
  19. RemoteIPTrustedProxy 2803:f800::/32
  20. RemoteIPTrustedProxy 2405:b500::/32
  21. RemoteIPTrustedProxy 2405:8100::/32
  22. RemoteIPTrustedProxy 2a06:98c0::/29
  23. RemoteIPTrustedProxy 2c0f:f248::/32" \
  24. > /etc/apache2/conf-available/realips.conf' \
  25. && sudo sed -i 's/LogFormat "%v:%p %h/LogFormat "%v:%p %a/g;s/LogFormat "%h %l/LogFormat "%a %l/g;'  /etc/apache2/apache2.conf
复制代码


前一部分是录入CF的IP地址,以realips配置文件来“过滤”出真实的访问的IP地址,后一部分是修改Apache服务器的日志记录,使之留下真实访问的IP地址信息。

建立完成上面这些配置后,运行如下代码,特别是Apache里的那个remoteip的配置文件我记得默认安装完是非激活的

  1. sudo a2enmod remoteip && sudo a2enconf realips
复制代码


根据实际情况,可能还有其它的一些配置文件需要这样激活,比如sudo a2enmod unique_id等,然后重新启动或载入Apache服务器。这样之后的访问日志记录中就能查看到真实的源IP地址了。

如果用的是Nginx,也有对应的插件,Nginx官方应该也有说明。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-5-14 17:12 , Processed in 0.061437 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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