Proxy/caching with Apache and index.html files

Igor Sysoev igor at sysoev.ru
Wed Aug 11 22:36:45 MSD 2010


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

> 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 for
> example, this would be served by nginx, but if I go to 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;
}

/dir/ > /dir/index.php case will be handled via internal redirect,
please, look this:
http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list