I just installed nginx version 1.2.5 on a new server and discovered that I can not change the default file for default website.

In /etc/nginx/sites-available/default file I have the following lines:

server {
listen 80 default_server;
    server_name myserver;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    root /var/www/default;
error_page 404 /4044.html;
    location / {
        index index.html index.htm;


server {
... server2...
server {
... server3...

Unfortunately, when I open a page by using server's IP address http://ip_address, instead of file /var/www/default/index.html nginx displays it's default file "Welcome to nginx". In case of 404 error it doesn't display the file /var/www/default/4044.html but it's default "not found"page.

I tried to change: listen 80 default_server; to listen 80 default; and server_name myserver; to server_name servers_ip_address

restarted nginx, but no success. Checked error.log file but nothing wrong. I have nginx installed on 2 more servers but olders versions of nginx. There are no problems like this.

Any ideas? If I cannot change its, does anyone knows wher default pages are located so that I can edit them? Thanks.

  • Are you sure, that you have symlink to this file in /etc/nginx/sites-enabled?
    – VBart
    Nov 17, 2012 at 13:04

3 Answers 3


For some reason new Nginx's configuration file doesn't include file /etc/nginx/sites-available/default. That was my problem.

  • well thats a debian specific behaviour. sites-available holds all your configuration files and sites-enabled holds all active configuration files. So to enable a site just use: sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/ Nov 20, 2012 at 18:50

This is old but if you can't figure out the answer take a look at Config Changes Not Reflected on the nginx wiki.

Try to clear your browser cache and see if the changes are reflected. As soon as I cleared my browser cache the "Welcome to Nginx" page never loaded again.


The is the correct behaviour based on your configuration. Then you load the IP address of the server, you will always get the first virtual server definition for that IP address, since nginx cannot determine the server name from the HTTP header.

If you want another server block to respond, simply move it to the first position for that IP address.

The HTML files fo the default server are located in /var/www/default, which is defined by the "root" directive (root /var/www/default;)

Having a default configuration for an IP is actually quite useful. I use it to automatically redirect from non www. address to www.somedomain.com like this:

server {
listen default;
server_name "_";
root /usr/local/nginx/html/whaever;
if ($host ~* ^[^.]+\.[^.]+$) { rewrite ^(.*)$ http://www.$host$1 permanent; }
  • 1
    gmck, that's the problem. If I load the IP I don't get the first virtual server definition. As I wrote, the document root for first virtual server is /var/www/default but nginx shows it's own default file "welcome to nginx". It's not the file that I have in /var/www/default. I want to know how to get rid of "welcome to nginx" file when I load server's IP. Nov 17, 2012 at 14:14
  • @gmck, you're doing it wrong: nginx.org/en/docs/http/converting_rewrite_rules.html and wiki.nginx.org/Pitfalls
    – VBart
    Nov 17, 2012 at 16:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .