nginx default server not working

I'm using Debian, most recent dotdeb nginx-lite. I've read that the first server section found by nginx will be used as the fallback/default section used if there is no specific server section for a domain.

I deleted sites-available and sites-enabled from my installation because I use a dedicated mount /www for everything http related.

My /etc/nginx/nginx.conf has these lines including other confs:

    include /www/conf.d/nginx/default.conf;
    include /etc/nginx/conf.d/*.conf;
    include /www/conf.d/nginx/*;

default.conf looks like:

server {
        server_name 0.0.0.0;
        listen 0.0.0.0:80;
        rewrite ^ http://mymaintarget.com permanent;
}

This does not work for me. I still get this warning:

Restarting nginx: nginxnginx: [warn] conflicting
server name "0.0.0.0" on 0.0.0.0:80, ignored

Im pretty sure there is no other server section and default.conf is the first one included / used.

Anybody knows what's wrong or how the correct way of configuring a default server is?

Update full config files:

nginx.conf:

user www-data;
worker_processes 8;
pid /run/nginx.pid;

events {
        worker_connections 768;
}

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 10;
        types_hash_max_size 2048;
        server_tokens off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        error_log /var/log/nginx/error.log;

        gzip on;
        gzip_disable "msie6";
        gzip_vary on;


        # Default VirtualHost
        include /www/conf.d/nginx/default.conf;

        # conf.d is empty anyways
        #include /etc/nginx/conf.d/*.conf;

        # VirtualHosts
        include /www/conf.d/nginx/*;
}

default.conf:

server {
        listen 80 default_server;
        rewrite ^ http://blog.flowl.info permanent;
}

Solution 1:

To set a default server:

server {
    listen 80 default_server;
    rewrite ^ http://mymaintarget.com$request_uri? permanent;
}

The default_server parameter will include any other domain, ip etc

More info nginx

Solution 2:

    # Default VirtualHost
    include /www/conf.d/nginx/default.conf;

    # conf.d is empty anyways
    #include /etc/nginx/conf.d/*.conf;

    # VirtualHosts
    include /www/conf.d/nginx/*;

"default.conf" gets included, and then gets included again in /www/conf.d/nginx/*

I removed the first include, and renamed "default.conf" to "_default.conf" so the file is the first to be included in the wildcard include.