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

时间:2016-10-13 09:44:54

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

我需要在AWS上使用SSL创建node.js应用程序以支持PayPal付款。我不知道如何配置和配置。我目前正在运行应用程序,但纯粹基于HTTP(而不是HTTPS)。请提供有关最佳配置方法的选项。 我在一个窗口服务器上 - 这有两个部分 1)如何配置AWS? 2)如何配置节点?

2 个答案:

答案 0 :(得分:0)

只需生成您的SSL证书并在nginx conf中设置

示例: 您的应用程序在localhost:3000上运行 您的域名是test.com

在/ etc / nginx / sites-enable /中添加一个配置,例如包含以下内容的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请求

使用以下cmd测试配置:

$ sudo nginx -t

如果成功重新加载nginx:

$ sudo nginx -s reload

答案 1 :(得分:0)

如果您在EC2实例上运行节点,我会使用带有SSL证书的ELB。

http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-create-https-ssl-load-balancer.html

ELB和亚马逊证书管理员使这个愚蠢容易。

另一种选择是使用Elastic Beanstalk。更多关键和易于设置。 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.html