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

On my server, all requests to and go to my server's IP address correctly and the content is displayed accurately. However, if you go directly to the server's IP, the "Welcome to nginx!" default page is shown. I want requests directly to the server's IP to show the proper content. My server configuration is located below. I should also mention that merely adding the public IP or "" after "" on the "server_name" line does not change anything. Thank you.

server {
    listen 443 ssl spdy;
    root /var/www;

    ssl_certificate /etc/nginx/ssl/ssl.crt;
    ssl_certificate_key /etc/nginx/ssl/ssl.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    keepalive_timeout 70;
    include /var/www/wp-content/plugins/better-wp-security/rules.conf;
    location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
            index index.php index.html index.htm;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
          root /usr/share/nginx/www;

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            try_files $uri =404;

} server { listen 80; server_name; rewrite ^ https://$host$request_uri permanent; }

share|improve this question
up vote 2 down vote accepted

Your configuration for and is fine. What happens is that there is another "default" server defined in nginx (probably in main nginx.conf configuration file) which responds to requests by IP. You need to remove that catch-all server configuration.

share|improve this answer
Had to clear up the stuff in conf.d, but it doesn't have the same page now. It currently throws the SSL certificate error since doesn't match m.y.i.p and the site looks all text based, but all links redirect to the real domain anyway. I guess this is good enough. Thanks. – DrDinosaur Apr 20 '14 at 10:25
Can you accept the answer if this helped you? – phoops Apr 20 '14 at 10:45
If you want to get rid of the certificate error, you have to get a new certificate that has both the domain and IP address in its Subject field. – Tero Kilkanen Apr 21 '14 at 16:14

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.