Config help - Reverse Proxy for Virtual Directories

Gavin Kistner phrogz at mac.com
Fri Feb 20 08:52:07 MSK 2009


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?

Thanks in advance for any help.





More information about the nginx mailing list