Nginx wildcard DNS, with www, without www and with subdomain

-1

I have a Ngnix server with the following configuration:

server {
    listen 80;
    server_name .dominio.com.br;
    root /home/dominio.com.br/public;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/dominio.com.br-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

I configured the DNS in my domain as follows:

Type A record with name @ pointing to the IP of my server Record type CNAME with name www pointing to @ Record type CNAME with name * pointing to @

If I enter using the address dominio.com.br it goes normal. If I enter using the address www.dominio.com.br it redirects to dominio.com.br without www (I do not want that to happen) If I enter using the address qualquercoisa.dominio.com.br it accesses normal also without redirecting.

If the person enters any of these links informed above everything should be pointing to the same application that is in the folder /home/dominio.com.br/public

If the person enters entering only domain.com I will redirect to www.dominio.com.br

Why is www redirecting to www ? Can you tell me where I'm wrong or what I'm missing?

    
asked by anonymous 08.09.2014 / 15:17

1 answer

0

I believe that using the following form can solve your problem.

server_name  *.example.org;
    
08.09.2014 / 18:20