URL-Rewriting not working

Anoop Alias anoopalias01 at gmail.com
Sat Apr 8 13:40:33 UTC 2017


The 404 is thrown by whatever is working on port 2000 ;so you can check its
access log and see


On Sat, Apr 8, 2017 at 6:54 PM, Ajay Garg <ajaygargnsit at gmail.com> wrote:

> 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
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>



-- 
*Anoop P Alias*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20170408/96c692c9/attachment.html>


More information about the nginx mailing list