使用 unicorn + nginx 运行 rails 有一段时间了,之前 nginx 这样配置 ip 地址
proxy_set_header X-Real-IP $remote_addr;
发现 rails 中获取到的 ip 是 127.0.0.1 , 然后又配置 CLIENT_IP
proxy_set_header CLIENT_IP $remote_addr;
这样配置之后就发现了 rails 的错误
ActionDispatch::RemoteIp::IpSpoofAttackError
原来 rails 有 ip 防欺骗,再改 ningx 配置,加入
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
之后就 ok 了,想来想去这个防 ip 欺骗,是防不住的啊