<div dir="ltr">I am using lua to parse out the username of the posted form and if the username == user and password == password.<div><br></div><div>I want to change the URI to <a href="http://www.somesite.com//forum/unauthorized.html">http://www.somesite.com//forum/unauthorized.html</a></div><div><br></div><div>otherwise, I want it just to do:</div><div><br></div><div>proxy_pass http://$http_host$uri$is_args$args;<br></div><div>(<a href="http://somesite.com.com/forum/ucp.php?mode=login">http://somesite.com.com/forum/ucp.php?mode=login</a>)</div><div><br></div><div>The unauthorized.html is located in /data/www/ on the nginx server.</div><div><br></div><div>Here is my nginx.conf:</div><div><br></div><div>







<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1">http {</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>include<span class="gmail-Apple-tab-span"> </span><span class="gmail-Apple-tab-span">        </span>mime.types;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>default_type<span class="gmail-Apple-tab-span">    </span>application/octet-stream;</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>sendfile<span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>on;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>keepalive_timeout<span class="gmail-Apple-tab-span">       </span>65;</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>gzip<span class="gmail-Apple-tab-span">    </span>on;</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>server {</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span>listen<span class="gmail-Apple-tab-span">  </span>80;</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span>location / {</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>resolver 8.8.8.8;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>lua_need_request_body on;</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>content_by_lua_block {</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">        <span class="gmail-Apple-tab-span">    </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>ngx.req.read_body();</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">        <span class="gmail-Apple-tab-span">    </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>local post_params = ngx.req.get_post_args();</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">        <span class="gmail-Apple-tab-span">    </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>local username;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">        <span class="gmail-Apple-tab-span">    </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>local password;</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">        <span class="gmail-Apple-tab-span">    </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>if (post_params) then</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">            <span class="gmail-Apple-tab-span">      </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>-- Iterate through post params</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">            <span class="gmail-Apple-tab-span">      </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>for key,value in pairs(post_params) do</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                <span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>if (key == "username") then</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                    <span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>username = value;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                <span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>elseif (key == "password") then</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                    <span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>password = value;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                <span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>end</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                <span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>-- ngx.say(key," : ", value);</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">            <span class="gmail-Apple-tab-span">      </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>end</span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">            <span class="gmail-Apple-tab-span">      </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>if (username and password) then</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">                <span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>--<span class="gmail-Apple-tab-span"> </span>ngx.say(username);</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>--<span class="gmail-Apple-tab-span">      </span>ngx.say(password);</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>if (username == "user" and password =="password") then</span></p>
<p class="gmail-p2">      <b>-- WHAT DO I DO HERE ?</b></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>end</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">            <span class="gmail-Apple-tab-span">      </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>end</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">        <span class="gmail-Apple-tab-span">    </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>end</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-converted-space">    <span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span></span>}<span class="gmail-Apple-tab-span">  </span></span></p>
<p class="gmail-p1"><span class="gmail-s1"></span><br></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span><span class="gmail-Apple-tab-span">        </span>proxy_pass http://$http_host$uri$is_args$args;</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span><span class="gmail-Apple-tab-span">        </span>}</span></p>
<p class="gmail-p2"><span class="gmail-s1"><span class="gmail-Apple-tab-span">  </span>}</span></p>
<p class="gmail-p2"><span class="gmail-s1">}</span></p></div>







<div><br></div><div><br></div></div>