# Proxy/caching with Apache and index.html files

**URL:** <https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063>\
**Category:** NGINX\
**Created:** [August 10, 2010, 4:56pm UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063 "2010-08-10T16:56:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattWard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@MattWard](https://www.ruby-forum.com/u/MattWard)\
**Post date:** [August 10, 2010, 4:56pm UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063/1 "2010-08-10T16:56:30Z")

</div>

Hi all,

I’ve got an nginx frontend/apache backend setup with nginx using  
proxy\_pass to pass requests for location / to my Apache server on  
localhost:8080. I’ve got a location setup to catch css/js/images/html  
etc. and serve them statically via nginx (fairly standard I believe).

My question is, this works for everything (including html files, which I  
want served statically via nginx) apart from default index.html files  
that are matched by /. If I were to go to [domain.com/index.html](http://domain.com/index.html) for  
example, this would be served by nginx, but if I go to [domain.com/](http://domain.com/) and  
the default file is an index.html file I want it served by nginx (as  
opposed to a default index.php file which would still be passed through  
to Apache). What config do I need to get nginx to recognise this special  
case?

Matt.

Posted at Nginx Forum:

> **[Proxy/caching with Apache and index.html files](https://forum.nginx.org/read.php?2,118322,118322#msg-118322)**
>
> Hi all, I've got an nginx frontend/apache backend setup with nginx using proxy\_pass to pass requests for location / to my Apache server on localhost:8080. I've got a location setup to catch css/js/images/html etc. and serve them statically via nginx...

---

<div class="post-metadata">

**Author:** ![MattWard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@MattWard](https://www.ruby-forum.com/u/MattWard)\
**Post date:** [August 11, 2010, 9:27am UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063/2 "2010-08-11T09:27:37Z")

</div>

It is not going to make any difference whether nginx or apache serves  
the file. Just leave things are they are.

Posted at Nginx Forum:

> **[Re: Proxy/caching with Apache and index.html files](https://forum.nginx.org/read.php?2,118322,118622#msg-118622)**
>
> Hi all, I've got an nginx frontend/apache backend setup with nginx using proxy\_pass to pass requests for location / to my Apache server on localhost:8080. I've got a location setup to catch css/js/images/html etc. and serve them statically via nginx...

---

<div class="post-metadata">

**Author:** ![MattWard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@MattWard](https://www.ruby-forum.com/u/MattWard)\
**Post date:** [August 11, 2010, 1:44pm UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063/3 "2010-08-11T13:44:00Z")

</div>

In which case, what would be the point in having nginx serve anything  
static at all in terms of JS and CSS files which are similar, or is  
there not any point in using nginx? Surely the advantage should either  
apply to both or not at all?

Posted at Nginx Forum:

> **[Re: Proxy/caching with Apache and index.html files](https://forum.nginx.org/read.php?2,118322,118677#msg-118677)**
>
> Hi all, I've got an nginx frontend/apache backend setup with nginx using proxy\_pass to pass requests for location / to my Apache server on localhost:8080. I've got a location setup to catch css/js/images/html etc. and serve them statically via nginx...

---

<div class="post-metadata">

**Author:** ![MattWard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@MattWard](https://www.ruby-forum.com/u/MattWard)\
**Post date:** [August 11, 2010, 8:37pm UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063/4 "2010-08-11T20:37:56Z")

</div>

On Tue, Aug 10, 2010 at 10:55:21AM -0400, MattWard wrote:

> example, this would be served by nginx, but if I go to [domain.com/](http://domain.com/) and  
> the default file is an index.html file I want it served by nginx (as  
> opposed to a default index.php file which would still be passed through  
> to Apache). What config do I need to get nginx to recognise this special  
> case?

With the following configuration nginx will pass \*.php requests to  
Apache:

location / {  
index index.html index.php;  
root /path/to/files;  
}

location ~ .php$ {  
proxy\_pass [http://lcoalhost:8080](http://lcoalhost:8080);  
}

/dir/ \> /dir/index.php case will be handled via internal redirect,  
please, look this:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration)**
>
> nginx first decides which server should process the request. Let’s start with a simple configuration where all three virtual servers listen on port \*:80:

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![MattWard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@MattWard](https://www.ruby-forum.com/u/MattWard)\
**Post date:** [August 12, 2010, 12:13pm UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063/5 "2010-08-12T12:13:58Z")

</div>

Exactly what I was looking for, thanks Igor 🙂

Posted at Nginx Forum:

> **[Re: Proxy/caching with Apache and index.html files](https://forum.nginx.org/read.php?2,118322,118962#msg-118962)**
>
> Hi all, I've got an nginx frontend/apache backend setup with nginx using proxy\_pass to pass requests for location / to my Apache server on localhost:8080. I've got a location setup to catch css/js/images/html etc. and serve them statically via nginx...

---

<div class="post-metadata">

**Author:** ![MattWard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/cdc98d/32.png) [@MattWard](https://www.ruby-forum.com/u/MattWard)\
**Post date:** [August 15, 2010, 9:53pm UTC](https://www.ruby-forum.com/t/proxy-caching-with-apache-and-index-html-files/193063/6 "2010-08-15T21:53:16Z")

</div>

Ha.

I thought you had Igor’s arrangement plus a static location to start  
with which is why I said leave as is but reading again, I see you were  
passing “/” to apache.

Glad you are sorted.

Posted at Nginx Forum:

> **[Re: Proxy/caching with Apache and index.html files](https://forum.nginx.org/read.php?2,118322,120102#msg-120102)**
>
> Hi all, I've got an nginx frontend/apache backend setup with nginx using proxy\_pass to pass requests for location / to my Apache server on localhost:8080. I've got a location setup to catch css/js/images/html etc. and serve them statically via nginx...
