nginx.conf文件上的nginx多个443 SSL服务器失败

时间:2018-11-04 14:20:13

标签: http ssl nginx https

我想在nginx 1.15.5上同时配置四个网站,而不是ssl。

如果我穿上etc / nginx / nginx.conf,则此配置将所有https连接重定向到第一个https服务器

server {
    listen       80;
    server_name  domain1.it;
    ...
}

server {
    listen       80;
    server_name  domain2.it;
    ...
}

server {
    listen       443 ssl;
    server_name  domain3.it;

    ssl_protocols TLSv1.2;
    ssl_certificate      /somepath/cert.cert;
    ssl_certificate_key  /somepath/key.key;
    ssl_trusted_certificate /somepath/cert.cert;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass  http://app1:8000;
    }
}

server {
    listen       443 ssl;
    server_name  domain4.it;

    ssl_protocols TLSv1.2;
    ssl_certificate      /somepath/cert.cert;
    ssl_certificate_key  /somepath/key.key;
    ssl_trusted_certificate /somepath/cert.cert;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass  http://app2:8000;
    }
}

请建议我如何解决此问题。 我需要在同一台机器ip上同时使用443 ssl和80的多个域。 所有这些域都将DNS重定向到相同的服务器IP。

0 个答案:

没有答案