惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

Rat's Blog - lnmp

宝塔面板LNMP开启Brotli压缩,可提高网站加载速度 - Rat's Blog 使用OneinStack搭建网站LNMP环境,并配置WAF防火墙防CC攻击 - Rat's Blog LNMP中一些隐藏的安装脚本及目录详解 - Rat's Blog LNMP一键安装包V1.5测试版已发布 - Rat's Blog LNMP环境下,利用Nginx反代Google网站的方法 - Rat's Blog LNMP环境下WordPress后台只显示一个主题预览的解决方法 - Rat's Blog LNMP环境下php-fpm启动失败的解决方法 - Rat's Blog lnmp1.4安装及部署typecho或其它博客教程 - Rat's Blog LNMP一键安装后Nginx不能自启的解决方法 - Rat's Blog
LNMP环境下使用CDN后获取访客真实IP的方法 - Rat's Blog
博主: Rat's · 2017-07-09 · via Rat's Blog - lnmp

说明:很多时候为了加速网站快速访问都会上CDN,这样一来程序和nginx日志获取到的访客IP地址就是CDN的节点IP而不是用户的真实IP了,这时候可以通过设置Nginx下的ngx_realip的模块是可以解决这个问题的,一般这个模块是默认没有添加的,不过军哥的lnmp是有这个模块的,所以设置会简单很多,这里说下具体方法。

方法

以军哥的lnmp为例,只需要添加些参数即可!

1、在lnmp安装目录/root/lnmp下找到lnmp.conf并编辑Nginx_Modules_Options

Nginx_Modules_Options='--with-http_realip_module'

保存后执行./upgrade.sh nginx来升级下Nginx就可以了。

2、找到网站配置文件,即/usr/local/nginx/conf/vhost/xx.com.conf并编辑。在任意一个location里加入以下参数:

set_real_ip_from  103.138.13.10/34;
set_real_ip_from  107.63.132.0/29;
set_real_ip_from  108.62.120.0/26;
set_real_ip_from  45.113.252.0/26;
real_ip_header    X-Forwarded-For;
real_ip_recursive on;

以上的IP地址换成你使用的CDNIP地址段。


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/204/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。