aws elastic beanstalk / S3 The page was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint

Viewed 583

I have a Spring boot application deployed using AWS Elastic Beanstalk, im using S3 bucket for my angular app. I have generated certifacate using aws certifacate manager and created CloudFront Distribution so my angular app is loaded on https. The problem is I am calling a rest API from Https deployed Application to Http Rest API. I keep getting this error: Mixed Content: The page at "https://mywebsite.com" was loaded over HTTPS, but requested an insecure XMLHttpRequest 'http://myendpoint'. This request has been blocked; the content must be served over HTTPS.

I tried generating my own certificate in my spring boot application it worked locally but once deployed on elastic beanstalk web services doesnt respond.

any tip on how use https / beanstalk ?

1 Answers

The error message sums the problem clearly. It would be a huge security issue to allow unencrypted data transfer, for seemingly securely encrypted web page.

Moreover, you don't really want to do SSL termination on your instances, for performance reasons, you don't want to manually manage keys an so forth.

In your situation, I would advise setting up a CloudFront distribution in front of your ALB (which I assume you have). That will solve your problems immediately, as CloudFront will automatically setup a domain for you and will expose your endpoints via HTTPS. Afterwards if you decide, you can easily setup a custom domain and certificates.

Finally, I recommend reading this article to make sure you avoid common pitfalls when configuring ALB and CloudFront.

Best, Stefan

Related