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

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

老张博客

Telegram群抽奖机器人,开源了! – 老张博客 [推广]酷鸭数据端午活动6.16开启!限时4天! – 老张博客 人有多大胆,AI有多大产! – 老张博客 老张博客更换Riven主题了! – 老张博客 wordpress兰空图床插件V2版 – 老张博客 WordPress首页调用typecho教程(1.3.0版) – 老张博客 typecho兰空图床上传插件V2版 – 老张博客 [推广]酷鸭数据 · 520情人节特别活动机来啦! – 老张博客 我只会瞎折腾!暨兰空图床上传图片失败解决方法! – 老张博客 再也不会去的“窑湾古镇” – 老张博客 困扰许久的网络问题终于解决了! – 老张博客 体验不佳的琅琊古城! – 老张博客 回复评论超时未解,老张博客再回酷鸭 目前老张博客服务器搭配方案! Tailscale+Lucky+雷池waf,多项组合让NAS更安全! NAS,如何做好安全防护!
WordPress反向代理后,获取不到访客真实IP的解决方法! – 老张博客
老张博客 · 2026-04-04 · via 老张博客

按目前《目前老张博客服务器搭配方案!》,把老张博客还是搬回了CloudCone。酷鸭数据香港这台VPS,因为线路好配置也高,只放个小博客有点性能过剩了,准备把openclaw安装上去,让我的"小张"搞一些项目!如果手里没有好性能、好线路的机器,酷鸭数据真的是不错的选择!

目前老张博客的服务器搭配是:访客 → 瓦工 Megabox(1panel 反代+WAF) → CloudCone(宝塔+WordPress),也就是在前天,有垃圾评论我准备拉黑IP地址的时候才发现,这个家伙的IP显示是我的瓦工 Megabox地址。出现这样的问题有两种可能,一是瓦工Megabox反代时没有把真实 IP 传递给 CloudCone,二是瓦工Megabox传递了真实IP但是 CloudCone 端的 WordPress 没有正确读取这真实IP。

在 1panel 反代配置中添加 Headers

在瓦工Megabox的 1panel 中,找到你的反向代理配置,添加以下 headers,具体步骤如下,并添加以下代码。注意,检查下,如果代码已存在,就不要再加了!经过检查,1panel的反向代理配置已经很完善了!

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;

经过第一步后,发现wordpress还是没有能正确的获取到访客的真实IP。我又检查到我的"老张随笔"是可以正确获取的访客真实IP的。那问题就是出在WordPress的配置上了。打开WordPress根目录下的 wp-config.php,在 <?php 之后第一行添加下面的代码

// 获取真实 IP(反代场景)
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip_list = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = trim($ip_list[0]);
} elseif (isset($_SERVER['HTTP_X_REAL_IP'])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
}

OK了,至此,WordPress就可以获取到访客的真实IP了!你学废了吗!