HTTP connection working on Elastic Load Balancer (Classic Load Balancer) but not on HTTPS - amazon-web-services

I am trying to set up an Elastic Load Balancer to be in front of my EC2 instance and redirect the traffic to it. My web app on EC2 is running HTTPS on port 3000. My ELB works nice when I start the web app over HTTP on port 3000 and I set up the ELB's port 80 to redirect HTTP traffic to HTTP 3000 of my instance. But when I start my app over HTTPS on port 3000 and then change the ELB's listeners, so it redirects HTTPS requests to port 80 to HTTPS 3000 of my instance, then the webpage does not work.
I have already created the SSL certificates, they are validated, uploaded to AWS Certificates Manager and my ELB is already taking them when serving HTTPS. My web app also has the certificate, so it's taking it to create the HTTPS environment on its side.
Also, my security group has connections on port 443 over HTTPS allowed.
Any suggestions, please?
Thanks in advance!

Related

Enabling SSL on webserver running on AWS EC2/Docker

I currently have a docker container hosted on ec2 and running a web server. The IP Address resolves perfectly when running it with just the IP address not using https but, when I put in the DNS it does not work. I am currently have the node port mapped to port 80 in the initial dockerfile. Then I mapped port 80 to port 443 in hopes on creating a Load Balancer using a certificate from ACM. This is not a docker issue and I was hoping someone had some insight on how to configure a Load Balancer to use SSL to talk back to my web server that has port 80 exposed. When putting domain.io:443 I get the nginx screen.
configure a Load Balancer to use SSL to talk back to my web server that has port 80 exposed.
For that you require to setup HTTPS in your target group, not HTTP. Also it requires self-signed certificate SSL on the container to server the HTTPS traffic.

Elastic Beanstalk with Classic Load Balancer working with HTTP but not HTTPS

I have set up a load Balancer to my elastic beanstalk app. It has provided a DNS / URL which works on http.
I have set up my domain on Route 53. I'm trying to make it work with HTTPS for a subdomain app.example.com
I have set up a wildcard certificate using ACM *.example.com.
I have enable HTTPS and port 443 on the loadBalancer. But I can't access it using the domain name https://app.example.com but works with http://app.example.com
In Route 53, I have created an A record with Alias set to the load Balancer DNS Name.
I have gone through tonnes of answers on stackoverflow but nothing worked for me. No idea what I'm missing.
You do not need to map 443 of the target as the TLS will terminate before sending the request to target.
Map 8080 port of the target to 443 of the load balancer.
Below diagram show SSL/TLS termination work with ALB.
SSL Certificates
To use an HTTPS listener, you must deploy at least one SSL/TLS server
certificate on your load balancer. The load balancer uses a server
certificate to terminate the front-end connection and then decrypt
requests from clients before sending them to the targets.
/application/create-https-listener
This is what worked for me. Changing Instance Protocol to HTTP in first row and changing Instance Port to 80.

AWS Aplication Load Balancer HTTP to HTTPS with EC2 instance

I have a EC2 instance running a Node.Js server on Ubuntu.
My goals are:
Connect my hosted zone to the EC2 instance
Route all incoming traffic from port 80 to port 3000 (because my server runs on port 3000)
and most importantly Use an Application Load Balancer to forward all requests to HTTPS (I already created a SSL Certificate in the Certificate Manager).
Currently, I am only able to open the website with the EC2 intances' Public Ip on port 3000 (http://prntscr.com/livali). Https requests or Http to port 80 don't work (http://prntscr.com/livau2). Altought a made an A record on my hosted zone with the instances' Public Ip, it's not possible to open the instance via the hosted zone (http://prntscr.com/liv9no).
I am really confused, as I am somehow not able to get this up and running. I would really appreciate a step by step guide on how to set this whole thing up.
If you already have a SSL certificate it is secure to use only port 443 instead of port 80.
Create an internet facing Application Load Balancer that listens on port 443 and routes traffic to your EC2 instance on port 3000.
Redirect users to HTTPS when accessing your domain on HTTP
See Docs > Load Balancer Listeners > Redirect Actions
Add an A record to point your domain name to the Load Balancer's public DNS.
These are web server concerns rather than DNS concerns. You'll need to set up something like NGINX or Apache to proxy port 80 to port 3000. See Apache redirect to another port for information.
You can also force HTTPS with a rewrite rule in Apache: https://wiki.apache.org/httpd/RewriteHTTPToHTTPS
Another option for forcing HTTPS is to create a CloudFront distribution and use that. https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https.html

Http to https redirection is not working

I am trying to configure the redirection for all http traffic to https only. My configuration as follows
We are using ELB and EC2 instances
Configured application Load Balancer in this case.
Backend server is working on port 443, using Nginx
Configured Nginx redirection rule for http to https redirection
Configured ELB listener for both port 80 and 443
Installed SSL Certificate in both backed servers and ELB
My Issue is when a client accesses this application over https URL is working fine in https. But when the clients try to connect this application over http, it is working in http and not redirect it into https.
I need to work this application only in https. How can we force all client communication into https?
Are you checking the right values in the redirect settings? The ALB should set x-forwarded-port and x-forwarded-proto.
Another option would be to use cloudfront in front of your ALB, and set it to force everything to https.

How to run my website as https which is running as Docker swarm cluster in AWS?

I am working on docker swarm and aws. I am not having much idea in it.
Please correct me if my question is wrong and kindly help me to solve my problem.
I have my docker swarm cluster running in AWS under a loadbalancer.
I created a certificate from Amazon certificate Manager for https to my load balancer.
In loadbalancer tab under listener if I set https for load balancer protocol and http to instance protocol like below, when I type https://website-url in the browser it automatically redirects to http.
LoadBalancerProtocol LoadBalancerPort InstanceProtocol InstancePort Cipher SSL Certificate
HTTPS 443 HTTP 80 Change 6e7528d6-8261-4d61-b1d3-3c2548e1b575 (ACM) Change
But I want the website to be run as https not as http.
So I changed like below. That is making Instance port and its protocol as 443 and https.
LoadBalancerProtocol LoadBalancerPort InstanceProtocol InstancePort Cipher SSL Certificate
HTTPS 443 HTTPS 443 Change 6e7528d6-8261-4d61-b1d3-3c2548e1b575 (ACM) Change
But After this https://website-url is continuously running without any response in the browser.
After doing some search, I came to know that ACM certificate only works for load balancer not for backend instance.
That is for instance level I need to enable https for apache.
The docker swarm cluster has 1 manager and 3 worker nodes. All the host instance OS is Alpine OS. The containers inside the nodes are Centos-7.
The containers are running as a service in the cluster.
Please guide me on this,
Do I need to configure self signed certificate for apache inside the container or on the host instance.
I want my website to be run as https not http.
Kindly show me What are the steps required.
Thanks
The load balancer port is what people talk to your load balancer on, so load balancer port 80 and 443 is correct.
The instance port is what port the load balancer talks to your webserver on. In this case for you both should be 80, unless your webserver is listening on 443 with a valid SSL cert (Not the case as you are using an AWS cert.)
Then in your code or your webserver what you need to do is check the X-Forwarded-Proto header http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html and if it's not https re-direct to https.
https://www.allcloud.io/how-to/how-to-force-https-behind-aws-elb/ has a couple examples.