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

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

Rat's Blog - Nginx

使用Nginx反向代理,自建CDN加速节点 - Rat's Blog LNMP环境下,利用Nginx反代Google网站的方法 - Rat's Blog Nginx环境下对部分网站做防盗链设置及外链的跳转 - Rat's Blog CentOS 7安装配置Nginx 1.10、PHP 5.6、MySQL 5.7教程 利用Nginx反向代理来简单镜像HTTP(S)网站的方法 - Rat's Blog Nginx给网站添加用户认证配置( Basic HTTP authentication) - Rat's Blog Nginx环境使用auth_basic密码保护wordpress后台登录界面 - Rat's Blog Nginx环境开启ssl后强制https 301全部指向www的方法 - Rat's Blog 防止Linux VPS主机Nginx环境根目录被解析的方法 - Rat's Blog
LNMP环境下使用CDN后获取访客真实IP的方法 - Rat's Blog
博主: Rat's · 2017-07-09 · via Rat's Blog - Nginx

说明:很多时候为了加速网站快速访问都会上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个机房按小时计费,支持支付宝,【点击查看】。