【问题标题】:How to configure HTTPS for node js with NGINX in windows如何在 Windows 中使用 NGINX 为节点 js 配置 HTTPS
【发布时间】:2019-04-27 13:35:01
【问题描述】:

我必须编写一些配置代码,但它不起作用。所以我要如何解决这个问题

   server {
  listen       3000;
  listen       443 ssl;
  server_name  localhost;

        ssl_certificate  /nginx-1.15.12/ssl/server.crt; // own certificate
        ssl_certificate_key /nginx-1.15.12/ssl/server.key; //own privatekey
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

  location / {
    proxy_pass https://10.0.0.4:3000;  //my local IP with node js running port number
    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;
  }

  location /public {
    root C:\Program-Files\iisnode\www\RSRK_BETA; // path of my node js application
  }

}

我想运行 HTTPS

【问题讨论】:

    标签: node.js windows nginx https


    【解决方案1】:
    server {
        listen 443 ssl;   
        server_name localhost;
        ssl_certificate     /path/to/cert-storage/cert-self-signed.com.crt;
        ssl_certificate_key /path/to/cert-storage/cert-self-signed.com.key;    
    ... 
        } 
    
    }
    

    我在 Linux 上运行 Node 10 + NGINX。我不确定操作系统是否会对 NGINX 本身产生影响。这就是我所拥有的,除了location 设置,它可以工作。

    【讨论】:

    • 另外,我建议使用 Cloudflare 作为代理,除了具有很酷的免费功能(例如提供额外的安全层或静态文件缓存)外,它还可以为您提供进出客户端的 SSL 流量,免维护自我更新,Cloudflare 证书,而 CF 本身可以让您永远使用自签名,甚至过时的证书。这让 SSL 得到了很好的解决,永远。
    • 我有自己的证书。不是自签名证书
    • 您是否拥有“官方”证书,而不是自签名证书,在这里并不重要。我评论的重点是,即使使用自签名,你的生活也会变得更轻松。我的回答的重点是,您可以从一个简单的配置开始(例如适合我的配置),以排除可能的错误,并在您启动并运行后逐渐添加所需的参数。
    猜你喜欢
    • 2017-07-05
    • 2021-04-05
    • 1970-01-01
    • 2018-07-03
    • 2021-09-28
    • 2018-03-09
    • 2016-02-19
    • 1970-01-01
    • 2015-05-16
    相关资源
    最近更新 更多