# Static homepage at root

**URL:** <https://www.ruby-forum.com/t/static-homepage-at-root/187499>\
**Category:** NGINX\
**Created:** [April 24, 2010, 3:02am UTC](https://www.ruby-forum.com/t/static-homepage-at-root/187499 "2010-04-24T03:02:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yourenew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yourenew](https://www.ruby-forum.com/u/yourenew)\
**Post date:** [April 24, 2010, 3:02am UTC](https://www.ruby-forum.com/t/static-homepage-at-root/187499/1 "2010-04-24T03:02:38Z")

</div>

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](http://aya);  
include proxy.conf;  
}

Posted at Nginx Forum:

> **[Static homepage at root](https://forum.nginx.org/read.php?2,78633,78633#msg-78633)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![yourenew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yourenew](https://www.ruby-forum.com/u/yourenew)\
**Post date:** [April 24, 2010, 11:12am UTC](https://www.ruby-forum.com/t/static-homepage-at-root/187499/2 "2010-04-24T11:12:25Z")

</div>

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](http://aya);  
> include proxy.conf;  
> }

Maxim D.

---

<div class="post-metadata">

**Author:** ![yourenew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eada6e/32.png) [@yourenew](https://www.ruby-forum.com/u/yourenew)\
**Post date:** [April 24, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/static-homepage-at-root/187499/3 "2010-04-24T12:04:30Z")

</div>

On Sat, Apr 24, 2010 at 03:01, yourenew [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](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](http://aya);  
include proxy.conf;  
}
