今天在排查这个问题, 发现 Google 会在 X-Forwarded-For 头给你发来两个 IP, 分别是真实 IP 还有 Load Balancing 的外网 IP.
在 Nginx 下, 配置了
set_real_ip_from 130.211.0.0/22; // Google IP real_ip_header X-Forwarded-For;
之后发现获得的竟然是 Load Balancing 的外网 IP. 查了一些的资料, 加上这两行, 就可以正确获得 IP 了.
set_real_ip_from (你的 Load Balancing 的外网 IP); real_ip_recursive on;
![]() | 1 wenjianhn 2016-06-01 18:12:33 +08:00 这个不是坑吧。。。 |
3 canglaoshi 2016-06-02 11:16:51 +08:00 googlecdn 好用么。我是没配置成功过。 |
![]() | 4 cst4you OP @canglaoshi 速度是可以的, 配置略繁琐(有 https 的情况下) |