简体   繁体   English

在Amazon EC2上无法使用HTTPS Node.js服务器

[英]Not working HTTPS Node.js Server on Amazon EC2

My site is not working on HTTPS. 我的网站没有使用HTTPS。 Now it is working good on HTTP. 现在它在HTTP上运行良好。

We added below code in server.js file, but we have no idea how to get private-key.pem and scr.pem files. 我们在server.js文件中添加了以下代码,但我们不知道如何获取private-key.pemscr.pem文件。

key: fs.readFileSync('./privatekey.pem'),
cert: fs.readFileSync('./server.crt')

Can someone tell me what I need to fix to enable HTTPS? 有人能告诉我需要修复什么来启用HTTPS吗?

To get those files you have 2 options: 要获取这些文件,您有2个选项:

  1. Generate private key and certificate on your machine using some tool like openssl, keygen, etc. 使用openssl,keygen等工具在您的计算机上生成私钥和证书。

  2. Purchase it online or some sites gives it away free for testing. 在线购买或某些网站免费提供测试。

After you get those files, put the correct path and filename. 获取这些文件后,请输入正确的路径和文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM