URL-Rewriting not working

Ajay Garg ajaygargnsit at gmail.com
Sat Apr 8 13:09:59 UTC 2017


Hi All.

When I setup the following, the authentication+proxying works perfect, with
the url changing from http://1.2.3.4:2001 to
http://1.2.3.4:2001/cgi-bin/webproc, and the proxied0server opening up
perfectly.

############################################################################
server {
        listen 2001;
        location / {

                        auth_basic 'Restricted';
                        auth_basic_user_file
/home/2819163155b64c4c81f8608aa23c9faa/.htpasswd;
                        proxy_pass http://127.0.0.1:2000;
                }
        }
#############################################################################



However, I am not able to do the proxying if I perform url-rewriting.
Nothing of the following works ::

a)
############################################################################
server {
        listen 2001;
        location /78 {

                        auth_basic 'Restricted';
                        auth_basic_user_file
/home/2819163155b64c4c81f8608aa23c9faa/.htpasswd;
                        proxy_pass http://127.0.0.1:2000;
                }
        }
############################################################################

No URL change happens, and 404 (illegal-file-access) is obtained.


b)
############################################################################
server {
        listen 2001;
        location /78 {

                        auth_basic 'Restricted';
                        auth_basic_user_file
/home/2819163155b64c4c81f8608aa23c9faa/.htpasswd;
                        proxy_pass http://127.0.0.1:2000/;
                }
        }
############################################################################

No URL change happens, and 404 (illegal-file-access) is obtained.


c)
############################################################################
server {
        listen 2001;
        location /78/ {

                        auth_basic 'Restricted';
                        auth_basic_user_file
/home/2819163155b64c4c81f8608aa23c9faa/.htpasswd;
                        proxy_pass http://127.0.0.1:2000/;
                }
        }
############################################################################

The URL does changes from http://1.2.3.4:2001/78 to
http://1.2.3.4:2001/cgi-bin/webproc, but a 404 is obtained.


d)
############################################################################
server {
        listen 2001;
        location /78/ {

                        auth_basic 'Restricted';
                        auth_basic_user_file
/home/2819163155b64c4c81f8608aa23c9faa/.htpasswd;
                        proxy_pass http://127.0.0.1:2000;
                }
        }
############################################################################

No URL change happens, and 404 (illegal-file-access) is obtained.


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.


Any ideas please?


Thanks and Regards,
Ajay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170408/25addbc5/attachment.html>


More information about the nginx mailing list