Config help - Reverse Proxy for Virtual Directories
Igor Sysoev
is at rambler-co.ru
Tue Feb 24 12:35:03 MSK 2009
On Fri, Feb 20, 2009 at 10:17:17PM -0700, Gavin Kistner 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?
location ^~ /ObjJob {
root /var/www/phrogz.net/ObjJob/public/;
rewrite ^/ObjJob(/.+) $1 break;
- rewrite ^/ObjJob(/.+) $1 break;
+ rewrite ^/ObjJob(/.+) $1;
as the "break" stops script execution and script does not run next "if"s:
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
proxy_pass http://localhost:9901;
break;
}
}
> What's the right way to set up a virtual directory like this?
No. The right way is
locaiton /ObjJob/ {
alias /var/www/phrogz.net/ObjJob/public/;
error_page 404 = @9901;
}
location @9901 {
proxy_pass http://localhost:9901;
}
or if you use modern try_files:
locaiton /ObjJob/ {
alias /var/www/phrogz.net/ObjJob/public/;
try_files $uri @9901;
}
location @9901 {
proxy_pass http://localhost:9901;
}
> 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.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list