node.js - 如何在 AWS 上使用 SSL 创建 node.js 应用程序?

标签 node.js amazon-web-services ssl paypal amazon-elb

我需要在 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/

相关文章:

java - AWS 源代码错误?

php - 学习基本网络安全的最佳方法

node.js - 当电子邮件或密码为空时, Passport 本地策略不会被调用

node.js - AWS Lambda TooManyRequestsException : Rate Exceeded

javascript - 使用路由文件中的 Express 和访问模块组织 Node 应用程序

amazon-web-services - cloudformation中Elasticache集群的引用arn

ssl - boringssl 可以在裸机 ARM 系统中工作吗?

ssl - 端口 443 工作但不是 https

ajax - 实时股票行情研究 - 使用 Ajax 和 PHP 或 Socket.io 和 Node.js 或者 Flash 或 Ruby on Rails

node.js - 将选项设置为 Mongoose 架构中的数组字段