简体   繁体   中英

How do I create a node.js application with SSL on AWS?

I need to create a node.js application on AWS with SSL to support PayPal payment. I am not sure how to configure and what to configure. I currently have the application running but purely on HTTP (not HTTPS). Please provide options on the best ways to configure. I am on a Window Server - there are two parts to this 1) How do I configure AWS? 2) How do I configure Node?

Simply generate your SSL certificate and set it in nginx conf

Example : Your application is running on localhost:3000 Your domain is test.com

Add a configuration in /etc/nginx/sites-enables/ for example conf.conf containing the following

#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 will now manage your https request

Test the configuration with the following cmd:

$ sudo nginx -t

if success reload nginx :

$ sudo nginx -s reload

If you have node running on an EC2 instance I would use an ELB with an SSL cert.

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

An ELB and a Amazon Cert Manger make this stupid easy.

Another option would be to use Elastic Beanstalk. Much more turn key and easy to setup. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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