我需要在 AWS 上使用 SSL 创建一个 node.js 应用程序以支持 PayPal 支付。我不确定如何配置以及配置什么。我目前正在运行应用程序,但纯粹是在 HTTP(而不是 HTTPS)上运行。请提供有关最佳配置方法的选项。 我在 Window 服务器上 - 这有两个部分 1) 如何配置 AWS? 2) 如何配置 Node ?
最佳答案
简单地生成你的 SSL 证书并在 nginx conf 中设置它
例子: 您的应用程序正在 localhost:3000 上运行 您的域名是 test.com
在/etc/nginx/sites-enables/中添加配置,例如 conf.conf 包含以下内容
#redirect http to https
server {
server_name test.com;
listen 80;
return 301 https://$server_name$request_uri;
}
server{
listen 443 ssl;
server_name test.com;
ssl_certificate YOUR_CRT_FILE.crt;
ssl_certificate_key YOUR_CRT_KEY.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_pass http://localhost:3000;
}
}
nginx 现在将管理您的 https 请求
使用以下命令测试配置:
$ sudo nginx -t
如果成功重新加载 nginx :
$ sudo nginx -s reload
关于node.js - 如何在 AWS 上使用 SSL 创建 node.js 应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40017566/