部署 如何使用 devise 正确的记录用户的 ip 信息?

nxbtch · October 07, 2014 · Last by nxbtch replied at October 08, 2014 · 2094 hits

项目是用 nginx 作为 proxy,然后用 devise 的 trackable 记录的地址永远都是 127.0.0.1, 应该如何配置 nignx 才能正确的在 rails 中得到用户真实的 ip 呢?

nginx

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

You need to Sign in before reply, if you don't have an account, please Sign up first.