5 messages in ru.sysoev.nginxRe: Config help - Reverse Proxy for V...
FromSent OnAttachments
Gavin KistnerFeb 19, 2009 9:51 pm 
Gavin KistnerFeb 20, 2009 9:16 pm 
MerlinFeb 23, 2009 6:52 pm 
Igor SysoevFeb 24, 2009 1:34 am 
Igor SysoevFeb 24, 2009 1:40 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Config help - Reverse Proxy for Virtual DirectoriesActions...
From:Igor Sysoev (is@rambler-co.ru)
Date:Feb 24, 2009 1:40:14 am
List:ru.sysoev.nginx

On Thu, Feb 19, 2009 at 10:52:07PM -0700, Gavin Kistner wrote:

I'm trying to get nginx to do the following (among other things):

If the URL matches /ObjJob/YYY if exists /var/www/phrogz.net/ObjJob/public/YYY, serve it statically otherwise proxy it to http://localhost:9901/YYY #no ObjJob

If the URL matches /SubSite2/ZZZ if exists /var/www/phrogz.net/SubSite2/public/ZZZ, serve it statically otherwise proxy it to http://localhost:9902/ZZZ #no SubSite2

If the URL doesn't match any of the above (/VVV) then if exists /var/www/phrogz.net/Phrogz/public/VVV, serve it statically otherwise proxy it to http://localhost:9900/VVV

My current config can be seen here: http://pastie.org/394796

The following URLs work as desired: http://localhost/static.css # serves from /var/www/phrogz.net/ Phrogz/public/static.css http://localhost/ # proxies to :9900 properly http://localhost/dynamic # proxies to :9900 properly

http://localhost/ObjJob/common.css # serves from /var/www/ phrogz.net/ObjJob/public/common.css

# The following 2 'work', but leave "ObjJob" at the front # of the path on the far side of the proxy; ideally I would like # the receiving process to think it's the only application around # with no knowledge of the "ObjJob" prefix. http://localhost/ObjJob # proxies to :9901 properly http://localhost/ObjJob/ # proxies to :9901 properly

My main problem, however, is that this fails: http://localhost/ObjJob/dynamic

I get an nginx 404, with this in the error log: open() "/var/www/phrogz.net/ObjJob/public/languages" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /ObjJob/languages HTTP/1.1", host: "localhost"

How can I fix my configuration to get this to work?

server { listen 80; server_name localhost;

access_log logs/phrogz_access.log main;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host;

location / { root /var/www/phrogz.net/Phrogz/public; error_page 404 = @9900; }

location /ObjJob { alias /var/www/phrogz.net/ObjJob/public; error_page 404 = @9901; }

location /SubSite2 { alias /var/www/phrogz.net/ObjJob/public; error_page 404 = @9902; }

location @9900 { proxy_pass http://localhost:9900; }

location @9901 { proxy_pass http://localhost:9901; }

location @9902 { proxy_pass http://localhost:9902; }

location /js { root /var/www/phrogz.net/; autoindex on; }

location /svg { root /var/www/phrogz.net/; autoindex on; }