问题
i'm trying to deploy my simple apollo-server on an Ubuntu 18.04 instance from Amazon Web Services(AWS) EC2. It works fine, but i need/want the traffic to be over HTTPS instead. I was wondering which could be the best option. Im running the code with "forever"("forever start lib/index.js"), also using yarn (to start the project "yarn start"). I'm able to access the server with the ip address () and everything works fine. I would like to do it ASAP, already tried with apollo-server-lambda and others Nodejs hosting websites.
回答1:
The easier way to do this on AWS is by using a EC2 load balancer. You just need to create an application load balancer and add your instance to the target group. Once you have the load balancer created, you can apply the SSL certificate easily on your load balancer. This approach doesn't require you to change your application code at all.
Please refer this docs. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/create-application-load-balancer.html
If you don't want to use a load balancer, you need to apply the SSL certificate on the application level. Hope this helps.
来源:https://stackoverflow.com/questions/59043089/apollo-server-on-ubuntu-18-04-ec2-instance-with-https