bedscape
Intern
Intern
  • UID2820
  • Fans0
  • Follows0
  • Posts1
Reads:2168Replies:2

Configure the HTTPS certificate for Node.js

Created#
More Posted time:May 30, 2017 6:34 AM
Hi All,


I generated the .key/.pem/.crt file, but how to configure the certificate to support HTTPS for my node.js app? I asked the Aliyun support, they said it was possible, but would not help.  In the node.js express program, I know how to use the .key and .pem file. Just do not know how to configure in the Alicloud.


Thanks a lot,


Jack

shhanshan
Forum Moderator
Forum Moderator
  • UID105
  • Fans5
  • Follows0
  • Posts343
1st Reply#
Posted time:Jun 12, 2017 18:23 PM
Didn't quite get your question.  Which service are you using to upload HTTPS certificate for node.js  ?  

If possible, please provide screenshot of your configuration page, please remove sensitive information in your screenshot, or you may submit another ticket to us.
AlibabaCloud.com

ankyit
Intern
Intern
  • UID6397
  • Fans0
  • Follows0
  • Posts5
2nd Reply#
Posted time:Nov 13, 2018 21:42 PM
Hi Jack,


What web server are you using to serve your NodeJs application? If you are using Nginx to serve the application then setting up the Nginx website configuration file in the following format will serve the website over HTTPS


Make sure to replace the server_name with your domain name or IP address.


Once the configuration is applied, restart your web server to apply the configuration changes.
 
server {
  listen       80;
  listen       443 ssl;
  server_name  your-domain-name.com;


  ssl_certificate  /etc/nginx/ssl/server.crt
  ssl_certificate_key /etc/nginx/ssl/server.key


  location / {
    proxy_pass http://localhost:3000;
    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 /usr/local/var/www;
  }


}
Guest