Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have finished setting up nginx for virtual hosting, this is how my config files look like

server {
    listen 80;
    server_name domain.com;
    access_log /home/domain.com/prod_webapp/logs/access.domain.com.log;
error_log /home/domain.com/prod_webapp/logs/error.domain.com.log;
    location /static {
            root /home/domain.com/prod_webapp/mocorner/ph/;
    }
location / {
    try_files $uri @uwsgi;
}
location @uwsgi {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/domain_uwsgi.sock; 
}}

on the same machine, I have domain1.com and domain2.com, each when i access I get its content which is great. My problem is that when i try to access the user using the IP address i get one of the sites in the virtual hosts too..

Although i disabled the default (removed the symbolic link) from sites-enabled folder but still not solved it for me.

any suggestions?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You may handle such requests by creating the default webserver configuration like this:

server {
    listen 80 default;
    server_name localhost;
}

This option is called default_server since 0.8.21. See documentation for details.

share|improve this answer
    
thanks this is helpful :) –  Mo J. Mughrabi Jun 24 '12 at 17:23
add comment

Just insert a catch all block and restrict access to every other request to your IP.

server {
    listen 80 default_server;
    server_name _;
    return 444;
}
share|improve this answer
add comment

Your Answer

 
discard

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.