<div dir="ltr"><div><div>Hi Anoop.<br><br></div>As per <a href="http://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite">http://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite</a>, the rewrite should be automatic.<br></div><div>But it does not work for me :(<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Apr 8, 2017 at 6:49 PM, Anoop Alias <span dir="ltr"><<a href="mailto:anoopalias01@gmail.com" target="_blank">anoopalias01@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think you are confusing between url-rewrite and location</div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sat, Apr 8, 2017 at 6:39 PM, Ajay Garg <span dir="ltr"><<a href="mailto:ajaygargnsit@gmail.com" target="_blank">ajaygargnsit@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div><div><div><div>Hi All.<br><br></div>When I setup the following, the authentication+proxying works perfect, with the url changing from <a href="http://1.2.3.4:2001" target="_blank">http://1.2.3.4:2001</a> to <a href="http://1.2.3.4:2001/cgi-bin/webproc" target="_blank">http://1.2.3.4:2001/cgi-bin/we<wbr>bproc</a>, and the proxied0server opening up perfectly.<br><br>##############################<wbr>##############################<wbr>################<br>server {<br>        listen 2001;<br>        location / {<br><br>                        auth_basic 'Restricted';<br>                        auth_basic_user_file /home/2819163155b64c4c81f8608a<wbr>a23c9faa/.htpasswd;<br>                        proxy_pass <a href="http://127.0.0.1:2000" target="_blank">http://127.0.0.1:2000</a>;<br>                }<br>        }<br>##############################<wbr>##############################<wbr>#################<br><br><br><br></div>However, I am not able to do the proxying if I perform url-rewriting.<br></div>Nothing of the following works ::<br><br></div>a)<br>##############################<wbr>##############################<wbr>################<br>server {<br>        listen 2001;<br>        location /78 {<br><br>                        auth_basic 'Restricted';<br>                        auth_basic_user_file /home/2819163155b64c4c81f8608a<wbr>a23c9faa/.htpasswd;<br>                        proxy_pass <a href="http://127.0.0.1:2000" target="_blank">http://127.0.0.1:2000</a>;<br>                }<br>        }<br>##############################<wbr>##############################<wbr>################<br><br></div>No URL change happens, and 404 (illegal-file-access) is obtained.<br><br><br></div>b)<br>##############################<wbr>##############################<wbr>################<br>server {<br>        listen 2001;<br>        location /78 {<br><br>                        auth_basic 'Restricted';<br>                        auth_basic_user_file /home/2819163155b64c4c81f8608a<wbr>a23c9faa/.htpasswd;<br>                        proxy_pass <a href="http://127.0.0.1:2000/" target="_blank">http://127.0.0.1:2000/</a>;<br>                }<br>        }<br>##############################<wbr>##############################<wbr>################<br clear="all"><div><div><div><div><div><div><div><br>No URL change happens, and 404 (illegal-file-access) is obtained.<br><br><br></div><div>c)<br>##############################<wbr>##############################<wbr>################<br>server {<br>        listen 2001;<br>        location /78/ {<br><br>                        auth_basic 'Restricted';<br>                        auth_basic_user_file /home/2819163155b64c4c81f8608a<wbr>a23c9faa/.htpasswd;<br>                        proxy_pass <a href="http://127.0.0.1:2000/" target="_blank">http://127.0.0.1:2000/</a>;<br>                }<br>        }<br>##############################<wbr>##############################<wbr>################<br clear="all"><br>The URL does changes from <a href="http://1.2.3.4:2001/78" target="_blank">http://1.2.3.4:2001/78</a> to <a href="http://1.2.3.4:2001/cgi-bin/webproc" target="_blank">http://1.2.3.4:2001/cgi-bin/we<wbr>bproc</a>, but a 404 is obtained.<br><br><br></div><div>d)<br></div><div>##############################<wbr>##############################<wbr>################<br>server {<br>        listen 2001;<br>        location /78/ {<br><br>                        auth_basic 'Restricted';<br>                        auth_basic_user_file /home/2819163155b64c4c81f8608a<wbr>a23c9faa/.htpasswd;<br>                        proxy_pass <a href="http://127.0.0.1:2000" target="_blank">http://127.0.0.1:2000</a>;<br>                }<br>        }<br>##############################<wbr>##############################<wbr>################<br clear="all"><br>No URL change happens, and 404 (illegal-file-access) is obtained.<br><br><br></div><div>So, I guess c) is the closest to doing a url-rewrite, but I wonder why am I getting a 404, even though the URL-change is perfect.<br><br><br></div><div>Any ideas please?<br></div><div><br><br><div class="m_8933438911414209517m_5633751355435447435gmail_signature">Thanks and Regards,<br>Ajay<br></div>
</div></div></div></div></div></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailm<wbr>an/listinfo/nginx</a><span class="HOEnZb"><font color="#888888"><br></font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_8933438911414209517gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><b>Anoop P Alias</b> <div><br></div></div></div></div>
</font></span></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><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Regards,<br>Ajay<br></div>
</div>