"ngx.var.remote_addr" have different value when retrive it twice in lua

杨秉武 detailyang at gmail.com
Thu Aug 11 07:13:53 UTC 2016


I guess that the question is about the lua variable scope rather than nginx.
you should give the simplest lua script to reproduce the question in the
mail.

About lua variable scope, you can take a look at this
<https://github.com/openresty/lua-nginx-module#lua-variable-scope> writen
by agentzh:)

2016-08-11 15:04 GMT+08:00 石磊 <shilei at qiyi.com>:

> Hi,
>
>
>
> I am using nginx 1.4, and I did fetch the "ngx.var.remote_addr" more than
> once in lua script, but strange thing is sometimes I will get different
> “$remote_addr” in different line in the same lua script file.
>
> Some more information:
>
> 1.       I hook the lua script at rewrite_by_lua_file stage
>
> 2.       This happens when the client has more than one ip address with
> different Operators.
>
> 3.       The “remote_addr” I got are the ip addresses the client have
> from different Operators.
>
>
>
> I want to know how this happen, it is by design that the “$remote_addr”
> could be changed for a http request?
>
>
>
> Thanks!
>
>
>
> *石  磊*
>
> 技术产品中心云平台系统网络
>
>
>
> [image: 邮件签名logo]
>
>
>
> 爱奇艺公司
>
> 地址:北京市海淀区海淀北一街2号鸿诚拓展大厦17层
>
> 邮编:100080
>
> 手机:+86 138 1180 3496
>
> 电话:
>
> 传真:+86 10 6267 7000
>
> 邮箱:shilei at qiyi.com
>
> 网址:*www.iQIYI.com <http://www.iQIYI.com>*  www.ppstream.com
>
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160811/a0481e13/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 25521 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20160811/a0481e13/attachment.jpg>


More information about the nginx mailing list