Loading... 使用CDN的各种好处博主在之前的文章中也做过介绍,这里就不多讲了。自博客回归之际博主就做了腾讯云的CDN加速,一直以来都是直接通过腾讯云后台下载访问日志来查看网站的具体访问情况。所以这么久博主居然忽略掉了服务器的访问日志看到的并不是用户的真实IP而是腾讯云遍布全世界的CDN节点IP地址这个问题。那么怎么解决这个问题呢? 以下为使用Nginx自带realip模块的办法来解决这一问题。首先,找到Nginx服务的配置文件,也就是nginx.conf这个文件。如果你使用的是宝塔面板,则可以在软件管理,Nginx设置的配置修改栏中直接打开配置文件,然后在 “http{” 下方插入如下两行代码: set_real_ip_from 0.0.0.0/0; real_ip_header X-Forwarded-For; 插入完成以后保存配置文件,同时重新启动Nginx服务。 这个时候再去访问网站,通过后台查看单个网站的访问日志就会显示用户的真实IP地址了。 最后修改:2019 年 04 月 04 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏
9 条评论
我加cdn后一直出问题,后台设置还403
后台设置是指?另外你应该多看看日志是否是直接通过源站IP进行的扫描或者攻击。
我被搞了2个月后,现在稍微安静一点了。
访问被服务器拒绝了,保存东西都保存不了。查了好多方法还没解决呢
学习了
::aru:clap::
多谢分享
客气了。有时候看访问日志还是非常需要的。
有些伪装成机器人的非法访问是不会触发统计代码的统计结果的。你去看Nginx日志才是最准确的访问日志。套了CDN的站点Nginx日志会显示节点的IP所以才有了本文。还有,手机上收到多次推送评论并没有成功发上来,应该是评论过滤插件做了阻断!