Config help - Reverse Proxy for Virtual Directories

Merlin merlin at mahalo.com
Tue Feb 24 05:52:28 MSK 2009


Perhaps the new try_file directive and an internal backend are what you
need.  I'm still in 0.6.x land on my production boxes, but I think it is
something like this (from igor's docs):

location / {
    try_files      /system/maintenance.html
                   $uri  $uri/index.html  $uri.html
                   @mongrel;
}

location @mongrel {
    proxy_pass     http://mongrel;
}

This will try the given $uri, index.html as subdirectory, the uri as HTML
file, and finally resolve to the @mongrel backend.  If you are using 0.6.x
or if that doesn't work, you can always use the old school 404 redirector
like so:

location / {
  error_page 404 = @mongrel;
}

location @mongrel {
    proxy_pass     http://mongrel;
}


The rest of the magic is up to you (I think you have it anyway).
- Merlin

On Fri, Feb 20, 2009 at 9:17 PM, Gavin Kistner <phrogz at mac.com> wrote:

> Let me try this again, more tersely:
>
> Why does this (pared down) config...
>  http://pastie.org/395896
> ...give me a 404 when I use a URL like...
>  http://localhost/ObjJob/foo
> ...instead of proxying to port 9901 as desired?
>
> What's the right way to set up a virtual directory like this?
>
> The only 'fix' I've found so far is to comment out lines 29 and 32, causing
> all static files to be proxied and served by the proxy app instead.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090223/84ad113f/attachment.html>


More information about the nginx mailing list