Can't reach website anymore, only "Welcome to nginx!" page comes up.

October 27, 2016 215 views
Nginx Linux Commands LEMP Ubuntu

I am using Nginx to run my website on Ubuntu 14.04. I just got it setup a few days ago. Everything was working fine until my router ended up changing my IP address on my Ubuntu server last night. I didn't known my server was setup with the DHCP protocol, I thought it was static. When my website wouldn't come up this morning I determined the problem to be the new IP address. I still have a problem though. When I access my server with the new IP address I now get the "Welcome to nginx!" page. My website won't come up anymore. The only thing that changed was the IP address. I have since programmed my router to reserve the new IP address for my server so that it won't change again. I also changed my port forwarding IP on my router to use the new IP address so that when my DNS uses my public IP to locate my router it will be forwarded to my server. The thing that makes no since is that the new IP address just brings up the "Welcome to nginx!" page and not my website. All of my files are still in place and nothing else changed. Does anyone have any idea what happened?

Thanks in advance for any advice.

7 Answers

What about your Server blocks?
Make sure if you entered IP somewhere in server block to change it to new IP.
Also I can recommend verifying root directive, verify does it point to location of website.

If you use custom server block make sure it is enabled (i.e. symlinked from sites-available to sites-enabled).

I had the same problem for Nginx on Ubuntu 14.04. It was known to break it like that after update.
You can also try restarting it:

  • sudo service nginx restart

If you need help with Server Blocks, you can refer to How To Set Up Nginx Server Blocks (Virtual Hosts) on Ubuntu 14.04 LTS.

by Justin Ellingwood
Nginx is an incredibly powerful web server and reverse proxy. In this guide, we'll discuss how to set up server blocks on Ubuntu 14.04 in order to server multiple domains from a single server.

Thank you very much for your assitance.

I verified that I had not entered the IP anywhere in server block.
I also verified my root directive.

How do you symlink sites-available to sites-enabled?

Following is what my sites-available/default file looks like:

# You may add here your
#  server {
#       ...
# }
# statements for each of your virtual hosts to this file

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /usr/share/nginx/html;
        index index.php index.html index.htm;

        # Make site accessible from http://localhost/
        server_name visualcommproductions;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

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

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

        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
        #location /RequestDenied {
        #       proxy_pass http://127.0.0.1:8080;
        #}

        #error_page 404 /404.html;

        # redirect server error pages to the static page /50x.html
        #
        #error_page 500 502 503 504 /50x.html;

Thanks again

  • Looks good so far.
    Make sure your site is at /usr/share/nginx/html and not /var/www/html.
    If this site is in /var/www/html just change root directive to it in above file.

    There could be a problem with this line: server_name visualcommproductions. What is visualcommproductions? You can try changing server_name visualcommproductions toserver_name _`. This will match all input IP addresses.

    Don't forget to restart nginx with:

    • sudo service nginx restart

    Beside that you can verify Nginx configuration with:

    • sudo nginx -t

    If it outputs everything with OK, that means that there are no errors somewhere :)

Thank you again for your help.

Thanks for showing me how to verify the Nginx configuration with the $ sudo nginx -t command.

When I changed server_name visualcommproductions; to server_name _`; the configuration test failed. Maybe I did not enter it correctly. Wanted to confirm I did it right. I entered it with an underscore after name and then an apostrophe followed by a semicolon.

The configuration verification passed with the word visualcommproductions even though visualcommproductions is not the name of my server, it is the domain name of my website. I changed this to the host name of my server and it still passed the configuration verification test, but it didn't fix the problem. My website still isn't coming up.

Thank you.

  • try

    server_name visualcommproductions.com www.visualcommproductions.com;
    

    also make sure to change DNS settings appropriately after you change ip address.

Have another answer? Share your knowledge.