/etc/nginx/nginx.conf

...

http {
    ...    
    
    # www.domain1.com
    server {
            server_name domain1.com;
            return 301 $scheme://www.domain1.com$request_uri;
    }

    server {
            server_name www.domain1.com;
            root /var/www/domain1.com;
            index index.php index.html index.htm;
            include /etc/nginx/sites-enabled/domain1;
        }

    # domain2.net       
    server {
            server_name www.domain2.net;
            return 301 $scheme://domain2.net$request_uri;
    }

    server {
            server_name domain2.net;
            root /var/www/domain2.net;
            index index.php index.html index.htm;
            include /etc/nginx/sites-enabled/domain2;
    }

    ...
}

...
……

阅读全文