Static homepage at root

I’m trying to host a static homepage, but send all other queries on to
the proxy (which leads to django), but I’m having trouble getting it to
work. It seems to ignore the first location directive. Are these
correctly configured? (I’m running nginx 0.6.35 and Ubuntu 9.04)

listen 80;
location = / {
root /var/www/aya/htdocs/html/;
index index.html;
}
location / {
proxy_pass http://aya;
include proxy.conf;
}

Posted at Nginx Forum:

Hello!

On Fri, Apr 23, 2010 at 09:01:35PM -0400, yourenew wrote:

I’m trying to host a static homepage, but send all other queries on to the proxy (which leads to django), but I’m having trouble getting it to work. It seems to ignore the first location directive. Are these correctly configured? (I’m running nginx 0.6.35 and Ubuntu 9.04)

listen 80;
location = / {
root /var/www/aya/htdocs/html/;
index index.html;
}

This will cause internal redirect to /index.html. So you also
need to configure location to handle it.

location = /index.html {
  root /var/www/aya/htdocs/html/;
}

location / {
proxy_pass http://aya;
include proxy.conf;
}

Maxim D.

On Sat, Apr 24, 2010 at 03:01, yourenew [email protected] wrote:

I’m trying to host a static homepage, but send all other queries on to the proxy (which leads to django), but I’m having trouble getting it to work. It seems to ignore the first location directive. Are these correctly configured? (I’m running nginx 0.6.35 and Ubuntu 9.04)

that is a very common case, an static overlay in front an application.
The right solution is to use
the try_files directive
http://wiki.nginx.org/NginxHttpCoreModule#try_files

try something like:

location = / {
root /var/www/aya/htdocs/html/;
try_files $uri $uri/index.html @proxy;
}

location @proxy {
proxy_pass http://aya;
include proxy.conf;
}