Forum: NGINX trailing slash in location

Posted by amodpandey (Guest)
on 2012-11-18 14:25
(Received via mailing list)
Please help me understand

The below works

     location /stats/ {
        proxy_pass http://example.com;
     }

or

     location /stats {
        proxy_pass http://example.com;
     }

or

     location /stats {
        proxy_pass http://example.com/stats;
     }

or

     location /stats {
        proxy_pass http://example.com/stats/;
     }

or

     location /stats/ {
        proxy_pass http://example.com/stats/;
     }

But this does not work

     location /stats/ {
        proxy_pass http://example.com/stats;
     }

Smlly when stats is an upstream

This works

   location /stats {
     proxy_pass http://stats;
   }

but this does not

   location /stats {
     proxy_pass http://stats/;
   }

What difference it makes when we have uri in the proxy_pass?

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,232966,232966#msg-232966
Posted by Igor Sysoev (Guest)
on 2012-11-18 16:10
(Received via mailing list)
On Nov 18, 2012, at 17:25 , amodpandey wrote:

>     location /stats {
>
> But this does not work
>     proxy_pass http://stats;
>   }
>
> but this does not
>
>   location /stats {
>     proxy_pass http://stats/;
>   }

It should work. Probably "/stats/" > "/stats" does not work.

> What difference it makes when we have uri in the proxy_pass?

It does not work because nginx changes /stats/SOME/PAGE to 
/statsSOME/PAGE.

Please read for details:
http://nginx.org/en/docs/http/ngx_http_proxy_modul...


--
Igor Sysoev
http://nginx.com/support.html
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.