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 set 4 domains up using Nginx etc. and have an html folder structured as follows:


The problem is when I go to 123.456.789.012 I get the default Nginx page and my domains are actually at 123.456.789.012/site1/ etc. This makes sense to me, I know why it's doing it, all sites are in sub folders from the root.

Basically I want 123.456.789.012 to redirect to 123.456.789.012/site1/ but without the /site1/ attached. Is this possible without moving my files of site1 to the root?

Does it even matter leaving it as is? I can't imagine anyone wanting to browse my site via IP.

share|improve this question
"I want 123.456.789.012 to redirect to 123.456.789.012/site1/ but without the /site1/ attached" What? I can't understand this. – leonbloy Apr 21 '13 at 1:38
If there's no need to browse via IP then don't listen on your IP, only respond when someone comes in on – Drew Khoury Apr 21 '13 at 4:40
up vote 1 down vote accepted

Just add default_server parameter to directive listen for corresponding server {} section of nginx.conf

For example,

server {
    listen 80 default_server;

    location / {
        root /path/to/html/site1;

The default_server parameter, if present, will cause the server to become the default server for the specified address:port pair. If none of the directives have the default_server parameter then the first server with the address:port pair will be the default server for this pair.

share|improve this answer
Thanks. This solution made the most sense to me out of the two. Turns out I already had the default parameter and only had to add /site1 to the root path. Not sure why I didn't think to try that. – Xenor Apr 21 '13 at 9:42
Well this actually killed my PHPMyAdmin, which is also in html/ Probably because my config is wrong. I added some code to try fix that but it just loaded the PHPMyAdmin index without images or CSS. Edit: I fixed that by moving the PHPMyAdmin shortcut to the /site1/ directory. – Xenor Apr 21 '13 at 15:25
You did not mention anything about PHPMyAdmin, located in html, not any of siteN folders :) Glad to hear, anyway, that your issue is solved. – cadmi Apr 22 '13 at 9:49

Sounds like you're looking for the root directive:

server {
    # things;
    location / {
        root /path/to/site1/;
        # things;

Given how the question is worded, however, this might not be what you want. It would pay to read the documentation:

It would be helpful if you posted your nginx.conf also.

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.