search

Home  >  Q&A  >  body text

node.js - nginx服务器下使用https,该怎么配置nodejs?

自己在startssl上申请了证书,打算让网站支持https

用的是nginx代理,然后转发到nodejs

现在nginx配置成https了也显示成功了

想问nodejs用不用改成https 还是用以前的http就行?

我试着改成https不成功:提示安全证书有问题Your connection is not private

nginx相关代码:

   upstream nodejs {
                server 127.0.0.1:8090;
        }

        server {
                root /usr/share/nginx/myblog/public;
                #tryfiles $uri $uri/index.html @express;
                listen 443 ssl;
                ssl on;
                server_name tempwrite.msocca.com sxgift.cn my.sxgift.cn 10000h.top;

                ssl_certificate  /etc/nginx/conf.d/ssl/1_www.10000h.top_bundle.crt;
                ssl_certificate_key   /etc/nginx/conf.d/ssl/ssl_ca.key;

                ssl_session_timeout 5m;


                location / {
                  proxy_pass http://nodejs;
                }
                location ~.*\.(ico|jpe?g|png)$ {
                  expires 2d;
                }

        }
大家讲道理大家讲道理2946 days ago777

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-04-17 14:59:56

    If nginx deploys ssl, nodejs does not need to make any changes.

    You have configured so many server_names above, but the certificate file is a certificate for the 10000h.top subdomain name. Your server_name does not have a domain name that matches this certificate at all.

    After a quick guess, the domain name that can match the certificate and have normal access is: https://www.10000h.top/

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 14:59:56

    After ssl on, there is no need to add ssl after 443

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 14:59:56

    Encountered the same problem. Local windows nodejs (https)+443+host mapping, and local windows+nginx+433+nodejs (http) are no problem. But nginx+433+nodejs (http) on centos doesn’t work~ We are currently looking for solutions. . . .

    reply
    0
  • Cancelreply