未在server_name中定义的Nginx网站“捕获”子域

时间:2019-02-08 12:43:37

标签: nginx nginx-location

我具有以下nginx配置,以便为不同的应用程序提供不同的子域,并且遇到一些奇怪的行为。

  1. cpanel.mydomain:443有时有效,有时却无效。
  2. be.mydomain.com: 8080 效果很好,但是如果转到 be .mydomain.com: 443 ,则会显示该应用为 cpanel .mydomain.com: 443 定义的代码,即使强悍的cpanel.mydomain.com也具有特定的server_name。

我在这里想念什么?

server {
        listen 8081;
        server_name be.mydomain.com;

        ssl on;
        ssl_certificate /var/www/sitename/ssl/allswdomains.crt;
        ssl_certificate_key /var/www/sitename/ssl/allswdomains.key;

        location / {
                proxy_set_header Host $host;
                proxy_redirect off;
                proxy_pass http://127.0.0.1:8080;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}


server {

        listen 443;
        server_name cpanel.mydomain.com;

        ssl on;
        ssl_certificate /var/www/sitename/ssl/allswdomains.crt;
        ssl_certificate_key /var/www/sitename/ssl/allswdomains.key;

        root /var/www/sitename/fe;

        location / {
                #try_files $uri /index.html;
        }
}

server {

    listen 80;

    server_name mydomain.com www.mydomain.com;

    return 301 https://$host$request_uri;
}

server {

        listen 443;

        ssl on;
        ssl_certificate /var/www/sitename/ssl/allswdomains.crt;
        ssl_certificate_key /var/www/sitename/ssl/allswdomains.key;

        root /var/www/sitename/website;

        server_name www.mydomain.com mydomain.com;

        location / {
                #try_files $uri /index.html;
        }

}

0 个答案:

没有答案