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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

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个机房按小时计费,支持支付宝,【点击查看】。