使用ssl和非ssl的Nginx配置问题

时间:2017-04-20 05:56:00

标签: node.js nginx

我有两个网站,我想通过https发布,而对于子域,我想通过http发布。我的问题是子域的发布失败了。

https://www.my-domain.com //正在运作

http://crm.my-domain.com //无效(ssl阻止)

我的配置文件应该如何?

当前的配置文件:

server {

    listen 443 ssl;
    server_name www.my-domain.com;

    ssl_certificate     /var/www/my-domain/server/config/certificates/www_my-domain_com.crt;
    ssl_certificate_key /var/www/my-domain/server/config/certificates/www_my-domain_com_nokey.key;

    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

server {

    listen 80;
    server_name www.my-domain.com my-domain.com;
    return 301 https://www.my-domain.com$request_uri;
}

server {

    listen 443;
    server_name my-domain.com;
    return 301 https://www.my-domain.com$request_uri;
}

server {

    listen 80;
    server_name crm.my-domain.com;
    access_log /var/log/nginx/crm.my-domain.com.log;

    location / {
        proxy_pass http://localhost:8081;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

0 个答案:

没有答案