如何在Windows中使用NGINX为节点js配置HTTPS

时间:2019-04-27 13:35:02

标签: node.js windows nginx https

我必须编写一些配置代码,但是它不起作用。因此,我为解决此问题所做的工作

   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

1 个答案:

答案 0 :(得分:0)

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设置以外,这就是我所拥有的,并且可以使用。