Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a test setup for nginx+apache. I have nginx listening on port 80, apache on port 8080. Nginx is set up to deal out the static content, apache is there to deal out the dynamic content (at least until we can upgrade to php 5.3). My apache setup works fine, here's the server section for nginx:

server {

    listen           80;
    server_name  mediocregopher-test;
    index test.php;

    location ~ \.php$ {

    location ~ /\.ht {
        deny  all;

    location / {
        root   /var/www/html;

The issue is, my index page (test.php) needs to be proxy'd to apache as "" when someone requests "mediocregopher-test:80/". With this setup this isn't happening. I'm fairly new to nginx, but I've looked around and couldn't find any setups that would solve this (although the problem is so simple it seems like it would be). Any suggestions?

I'm using nginx 1.0.1, if that's at all relevant.

share|improve this question
There is no special setup required for an index page that should be proxied (i.e. if you have proxying working, it will work for the index page). I presume you have verified that Nginx will serve a static file (just make that 'test.htm' and create the file) to ensure that all other aspects of the Nginx setup are valid (i.e. it recognizes the server name, etc). You can also use the 'debug' parameter on error_log to help provide more information. Also - check your Apache log. (If you turn off Apache, a proxied request should return 'Bad Gateway') – cyberx86 Jul 6 '11 at 2:24
cyberx86 is correct that your setup is fine. In addition to making sure it's going to the right server block, make sure you've also reloaded the configuration. It isn't reparsed on every page load like .htaccess is. – Martin Fjordvald Jul 6 '11 at 10:19
up vote 1 down vote accepted


location = / {
share|improve this answer

Nginx sends the request to Apache as soon as it realizes that the requested URL ends on .php, so you should add the following line to your Apache configuration file:

DirectoryIndex test.php

You can find more information about DirectoryIndex and its scope on this URL:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.