<div dir="ltr">I guess that the question is about the lua variable scope rather than nginx.<div>you should give the simplest lua script to reproduce the question in the mail.</div><div><br></div><div>About lua variable scope, you can take a look at <a href="https://github.com/openresty/lua-nginx-module#lua-variable-scope">this</a> writen by agentzh:)</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-08-11 15:04 GMT+08:00 石磊 <span dir="ltr"><<a href="mailto:shilei@qiyi.com" target="_blank">shilei@qiyi.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="ZH-CN" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"><span lang="EN-US">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">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.
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Some more information:<u></u><u></u></span></p>
<p style="margin-left:18.0pt">
<u></u><span lang="EN-US"><span>1.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><span lang="EN-US">I hook the lua script at rewrite_by_lua_file stage<u></u><u></u></span></p>
<p style="margin-left:18.0pt">
<u></u><span lang="EN-US"><span>2.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><span lang="EN-US">This happens when the client has more than one ip address with different Operators.<u></u><u></u></span></p>
<p style="margin-left:18.0pt">
<u></u><span lang="EN-US"><span>3.<span style="font:7.0pt "Times New Roman"">      
</span></span></span><u></u><span lang="EN-US">The “remote_addr” I got are the ip addresses the client have from different Operators.<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">I want to know how this happen, it is by design that the “$remote_addr” could be changed for a http request?<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:13.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:gray">石<span lang="EN-US"> 
</span>磊</span></b><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#595959">技术产品中心云平台系统网络</span><span lang="EN-US" style="font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#595959"> 
<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:宋体;color:black"><img width="270" height="43" src="cid:image001.jpg@01D1F3E1.01826910" alt="邮件签名logo"></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family:宋体;color:black"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">爱奇艺公司<span lang="EN-US"> </span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">地址:北京市海淀区海淀北一街<span lang="EN-US">2</span>号鸿诚拓展大厦<span lang="EN-US">17</span>层<span lang="EN-US"> </span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">邮编:<span lang="EN-US">100080</span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">手机:+<span lang="EN-US">86 138 1180 3496</span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">电话:</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">传真:+<span lang="EN-US">86 10 6267 7000</span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">邮箱:</span><span lang="EN-US" style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif"><a href="mailto:shilei@qiyi.com" target="_blank"><span style="color:blue">shilei@qiyi.com</span></a></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:#919191">网址:</span><u><span lang="EN-US" style="font-size:9.0pt;font-family:"\005fae\008f6f\0096c5\009ed1",sans-serif;color:blue"><a href="http://www.iQIYI.com" target="_blank">www.iQIYI.com</a></span></u><span lang="EN-US"> 
<a href="http://www.ppstream.com/" target="_blank"><span style="color:blue">www.ppstream.com</span></a><u><span style="color:blue"><u></u><u></u></span></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div>

<br>______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br></blockquote></div><br></div>