URL-Rewriting not working

Ajay Garg ajaygargnsit at gmail.com
Sat Apr 8 13:24:16 UTC 2017


Hi Anoop.

As per
http://serverfault.com/questions/379675/nginx-reverse-proxy-url-rewrite,
the rewrite should be automatic.
But it does not work for me :(

On Sat, Apr 8, 2017 at 6:49 PM, Anoop Alias <anoopalias01 at gmail.com> wrote:

> I think you are confusing between url-rewrite and location
>
> On Sat, Apr 8, 2017 at 6:39 PM, Ajay Garg <ajaygargnsit at gmail.com> wrote:
>
>> 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
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
>
> --
> *Anoop P Alias*
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



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


More information about the nginx mailing list