Help With Locations and Proxying

Maxim Dounin mdounin at mdounin.ru
Mon Jun 21 23:11:33 MSD 2010


Hello!

On Mon, Jun 21, 2010 at 12:32:16PM -0600, Bryan Richardson wrote:

[...]

> From looking at the debug errors from Nginx, it looks like Nginx is
> trying to pass the /planner portion of the URL to the Ruby
> application, which I don't want because I don't have a route in my web
> application that matches /planner. Essentially, I'd like
> bryan.example.com/planner to become the root URL for my Ruby
> application, such that navigating to bryan.example.com/planner/admin
> would just pass the /admin portion of the URL to the Ruby application,
> but I'm not sure how to do that. I'm assuming it has something to do
> with some of the other proxy options available...

You instructed nginx to pass url as is and it does so.  If you want 
"/planner" portion to be stripped/replaced by something you have 
to use proxy_pass with uri component, i.e. ...

>   location /planner/ {
>     proxy_set_header X-Real-IP $remote_addr;
>     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>     proxy_set_header Host $http_host;
>     proxy_redirect   off;
> 
>     proxy_pass http://planner;

-     proxy_pass http://planner;
+     proxy_pass http://planner/;

Note trailing "/".

Maxim Dounin



More information about the nginx mailing list