Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have this setup with apache but want to move over to nginx. I'm not sure how I can accomplish this.

In apache I had it as ServerAlias *

What would be the nginx equivalent?

I've tried server_name default_server; and server_name _; but that doesn't seem to work. I just keep getting a 404 every time I visit any host but

Update It seems that serving static files is not a problem. So it is pointing correctly but PHP files are giving me a 404 error (using php-fpm). Any ideas?

share|improve this question
up vote 0 down vote accepted

Does the user for the php-fpm pool have the right permissions to read the PHP files in the directory? i.e. if Nginx is running as www-data:www-data (as mine does) but your php-fpm pool is running as "user:user", then does the "user" account have the right permissions on the webroot to be able to open the PHP files?

share|improve this answer
Yes it does. Using I can see what I'm supposed to be seeing. When I try to access it using I get a 404 error. – Meisam Mulla May 24 '12 at 8:02
Sounds like checking the php-fpm and/or nginx logs is the only way forward then, I haven't used your setup specifically but I see no reason why it shouldn't work. – gac May 24 '12 at 8:04
I see this error in the nginx error log: 2012/05/24 08:06:04 [error] 32072#0: *17 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock:", host: "" 2012/05/24 08:06:04 [error] 32072#0: *17 open() "/home/example/frontend/50x.html" failed (2: No such file or directory), client:, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php5-fpm.sock:", host: "" Any ideas? – Meisam Mulla May 24 '12 at 8:12
Ok it seems like the problem is with my php script itself. However I am unable to tell what the error is exactly. – Meisam Mulla May 24 '12 at 8:20
Found the issue instead of giving a 500 error it was showing a 404. – Meisam Mulla May 24 '12 at 8:56

Apparently an invalid server_name like _ should serve as a catch all virtual host.

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.