Home > Blockchain >  How to serve HTTPS data on an AWS elastic beanstalk instance
How to serve HTTPS data on an AWS elastic beanstalk instance

Time:08-12

I have an elastic beanstalk instance in which I have deployed my spring-boot application. By default elastic beanstalk gives you a URL for your environment over http.

While this works fine this has led to a lot of problems for me. I have the frontend (my react application) deployed on Vercel. I want my frontend app to get data from my elastic beanstalk app. Problem is the url is in http. On the console I get an error like this

Mixed Content: The page at '' was loaded over HTTPS, but requested an insecure resource ''. This request has been blocked; the content must be served over HTTPS.

which renders the app useless basically.

After hours of google I found out that I have to request the data over https because my vercel app is over https*(I might be very wrong here)* I've tried some solutions to get my elastic beanstalk app to serve the data on https to no avail.

Here is what I've tried

  1. I created a self signed ssl certificate using openssl and uploaded it to AWS via the AWS cli. I then went to my applications load balancer settings and added the ssl certificate . (This did not work, I cried) AWS Load balancer settings

  2. I used keytool to create yet another ssl certificate and added it to my resources folder and the corresponding settings in the application.settings file. I repackaged the jar file and redeployed it to AWS.(Still didn't work. Didn't cry this time though. I was out of tears)

Question How do I serve the data from my spring-boot app to my Vercel react app over https? Or any other method. Just anything that will work.

If one thing is clear from all that long nonsense I've told you up there is I don't know wtf I'm doing. Just following a bunch of tutorials which for all I know keep destroying my app and your time even more.

Now my app is broken and now I cant even load the static assets on the elastic beanstalk URL because I'm getting another error

400 Bad Request The plain HTTP request was sent to HTTPS port

I know that question is really long and maybe even wrong. Please help

CodePudding user response:

So once you have the SSL certificate ready this what you need to do in the AWS Elastic beanstalk to serve your application for https

Add a new listener to for port: 443 and select HTTPS

enter image description here

After this incase you are facing any certificate error while browsing the page, ensure that the URL mentioned in the certificate is matching the URL in browser

  • Related