简体   繁体   中英

What's the easiest way for server in ec2 instance return https traffic?

I have a Springboot application running in an EC2 instance (ubuntu-bionic-18.04-amd64). The program when run returns JSON responses on the default port 8080. The url looks like http://ec2-3-17-69-122.us-east-2.compute.amazonaws.com:8080/users/rayyanshaji/todos/ .

What I need to accomplish is https instead of http so that my frontend UI accepts incoming https traffic.

What I have tried so far: Got my own domain name from AWS Route 53, got a certificate using ACM(Amazon Certificate Manager) and used it to create an inbound HTTPS 443 Listener in an Elastic Load Balancer. Added security groups which allow inbound traffic on both port 80, and port 443.

I know that the above steps aren't gonna work, as this is what I get on running netstat -tulpn command

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -
tcp6       0      0 :::22                   :::*                    LISTEN      -
udp        0      0 127.0.0.53:53           0.0.0.0:*                           -
udp        0      0 172.31.39.227:68        0.0.0.0:*                           -

It seems that my server isn't configured to either accept https requests nor give out https responses.

I am quite stuck here now, as I'm not an expert using linux. I've just started learning deployment on EC2 instances. I searched a lot on solutions, but could rarely find anything on Java.

I really need this roadblock to be fixed, so that I can resume development on my project. Any advice would really be appreciated. Thanks in advance.

You are on the right path and it is appreciable that you are able to configure the load balancer with HTTPs listener and ACM certificate.

First I must tell you that your actual ec2 instance needs not to talk HTTPS as this will be handled by the load balancer. Load balancer will act as the SSL terminator for all the incoming connections. So all the SSL handshake will be between the clients and the load balancer. On the downstream of load balancer, it can talk to your ec2 instance to http port only, which means whether the request comes on HTTP/HTTPs port on load balancer, it can forward to your EC2 instance on HTTP port only.

So just configure your load balancer target groups to take input requests on different HTTP/HTTPs port and forward to your EC2 instance on the single HTTP port.

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