haproxy + nginx加勾下,ngx.var.remote_addr 得到的内网ip

186 views
Skip to first unread message

raymond wang

unread,
Sep 12, 2013, 9:34:45 AM9/12/13
to open...@googlegroups.com
hi 大家好:

我们网站是前端haproxy ,后面带几个nginx服务器。
使用ngx_lua里的ngx.var.remote_addr得到的是haproxy服务器所在的内网ip,有什么办法能得到用户的真实外网ip呢?


raymond wang

unread,
Sep 12, 2013, 9:41:46 AM9/12/13
to open...@googlegroups.com
hi,我自己找到方法了,使用ngx.var.http_x_forwarded_for 即可

apple

unread,
Sep 12, 2013, 11:41:19 AM9/12/13
to open...@googlegroups.com
--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html

apple

unread,
Sep 12, 2013, 11:43:56 AM9/12/13
to open...@googlegroups.com
ngx.var.http_x_forwarded_for 这个ip 是可以伪造的 貌似没有ngx.var.remote_addr 来的安全些 

在 2013-9-12,下午9:41,raymond wang <54raymond@gmail.com> 写道:

smallfish

unread,
Sep 12, 2013, 10:35:44 PM9/12/13
to open...@googlegroups.com
经过proxy转发之后一般都是这样的,x-forword-for其实也是前端proxy传到后端的。
实在想用remote_addr,在前端转发时候加上就ok了

--


2013/9/12 apple <8980...@qq.com>

raymond wang

unread,
Sep 13, 2013, 2:53:08 AM9/13/13
to open...@googlegroups.com
这个应该怎么加呢?能否详细说下

smallfish

unread,
Sep 13, 2013, 3:33:01 AM9/13/13
to open...@googlegroups.com

--


2013/9/13 raymond wang <54ra...@gmail.com>

raymond wang

unread,
Sep 13, 2013, 4:19:25 AM9/13/13
to open...@googlegroups.com
ok,研究下
Reply all
Reply to author
Forward
0 new messages