How to configure HTTPS on an ELB application? - amazon-web-services

I have a client application hosted on S3 with a custom domain on godaddy. Cloudfront is serving all of the http(s) requests - all of that is well and good. I have an SSL certificate through ACM. There is an input dialog on the UI that when submitted, makes a POST request to a flask application running on ELB, but this request is failing because ELB is not configured for HTTPS (i.e. chrome is blocking an HTTP request because of mixed-content). Requests to the HTTP version of the endpoint work fine, but HTTPS requests time out. How do I configure the ELB load balancer to accept HTTPS requests? I've modified the configuration of the load balancer like so: https://imgur.com/3zWpS7f but requests are still failing. Any tips? Much appreciated!!
EDIT: I've configured the load balancer with a security group that allows ingress on 443 with HTTPS but now i'm getting a "Not secure" message with Chrome. is this because the certificate is registered with a domain associated with the site and not this api? do i need a separate certificate? The error code from chrome is: err_cert_common_name_invalid

Related

CORS/HTTPS issue with Elastic Beanstalk and Load Balancers

We have a springboot backend api running on elastic beanstalk. Our domain is on route53 and uses the Certificate Manager to run as https.
To make an api request we send the request to a subdomain url (https://api.SomeWebsite.com ). In Route53 we direct that subdomain to an EC2 load balancer, which then points that at the beanstalk instance. Our beanstalk should be in http - we are using the LB as an SSL terminator.
We have listeners for incoming traffic on the LB as:
HTTP , Port 80 -> Redirect to HTTPS 443
HTTPS, Port 443 -> Redirect to Target, HTTP, OurBeanstalkENV.
I have triple checked that the https port points to the correct EB instance, and it does note http on the target selection.
The Issue: we keep getting either preflight failed due to no Access-Control-Allow-Origin (even though it's in the request header) or a timeout error error when make the requests. When we look at beanstalk logs, our springboot server has an error: java.lang.IllegalArgumentException: Invalid character found in method name... HTTP method names must be tokens...
Based on this error Springboot is receiving httpS requests, even though it should be receiving http via the load balancer. Does anyone know what could be wrong here?

Can't access server since switching to https on aws

I am deploying a MERN stack using EC2 on AWS.
I have created SSL certificates for the following domains:
example.com
*.example.com
www.example.com
The cname and cvalue for example.com and *.example.com are identical but they are different for www.example.com
I have set up target groups and a load balancer and edited the listener to redirect from http to https.
I have set up 3 different records in the hosted zone of route 53 so that www.example.com, *.example.com and example.com are directed to the loadbalancer
I can load https://example.com
http://example.com directs to https://example.com
When the website loads (either by typing http or https) it does not connect to the server.
I am getting the following error in the console:
Mixed Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://54.220.212.131:5000/events'. This request has been blocked; the content must be served over HTTPS.
54.220.212.131 is the site's IP and 5000 is the server's port. This is hard coded in the front end.
How should I get the client to send requests to the server for a https connection?
It sounds like you have two services running, a front-end service that you have correctly configured to run behind a load balancer, and a back-end service that you are connecting directly to via the server's IP address on port 5000.
Your backend on port 5000 is not secure, and that is exactly what the web browser's error is telling you. You need to configure all your services to run behind the load balancer. You need to create a second target group that sends traffic to port 5000 on your server, and setup a routing rule on the load balancer's listener to send all traffic for api.ticketglen.com to that target group. Then you need to change your hard-coded values in from http://54.220.221.131:5000 to https://api.ticketglen.com.
What worked for me was to create the SSL certificates from the server and delete them and the load balancer altogether from the AWS platform.
Process is outlined here

update insecure request on Application Load Balancer

I want to look for a feature on ALB AWS that can update http to https on its own just like in the NGINX load balancer , currently I have a website that uses wordpress but when using ALB, the website only shows text , is there another way to upgrade the url from http to https without having to edit the code?
Yes, you can redirect http to https as explained in AWS docs:
How can I redirect HTTP requests to HTTPS using an Application Load Balancer?
For that you need your own domain name. Once you have the domain you can the SSL certificate for HTTPS from Amazon Certificate Manager which you can deploy on your ALB.

NET::ERR_CERT_COMMON_NAME_INVALID

I have a web server hosted in AWS ECS using fargate with load balancer.
I added an https listener to the load balancer with a certificate I issued using AWS ACM.
The certificate is issued to a domain I own, the certificate got validated and I'm able to send https requests to the web server via the load balancer using postman.
But, when I open in the browser the url of the load balancer I'm getting the following error
NET::ERR_CERT_COMMON_NAME_INVALID
what am I doing wrong?
Thanks in advance
what am I doing wrong?
Your SSL cert is issued for your own domain, not for "the url of the load balancer". So it does not match and you get the error.
You have to use your own domain now to access your api/website. Browsers are very strict in ensuring that SSL cert and domain match. In terms of postman, you may have disabled these checks, or postman may not be as strict.
You can check postman's ssl checks as shown below:

Http to Https Redirecting not Working in AWS

I set up an EC2 Instance
I uploaded an SSL Certificate and set it up correctly (Working)
When i go to my site using https it loads properly therefore no error with the certificate
I created an application Load Balancer
I set everything up and set Redirecting in http to https port 443
This still doesn't redirect my http page requests
I tried the DNS Name (A Record) in in load balancer and it shows that the connection is not secure and then loads my website in http itself
Have i missed out any crucial part?
Any help is appreciated