skip to Main Content

I’m learning AWS, so I’m trying to deploy a backend in Spring Boot and a frontend in Next.js 14 using AWS services.

I have my backend endpoint like this: http://ec2publicIp:8081/api/routes on my EC2 instance, which I know works and can be consumed.

Additionally, I have my frontend successfully hosted on AWS Amplify, but it has an HTTPS URL that creates a conflict when I try to send a request to my backend.

As a solution, I’m considering giving HTTPS to my EC2 instance, but I can’t find the step-by-step instructions on how to properly do it.

I would appreciate any information on how to solve this issue, either by giving HTTPS to my EC2 instance or making my AWS Amplify setup use HTTP.

As a note, I’m using the free tier, so I would highly appreciate it if my solution doesn’t require a paid domain.

Mixed Content: The page at 'https://main.NEXTAPP.amplifyapp.com/login' was loaded over HTTPS, but requested an insecure resource 'http://ec2publicIp:8081/auth/login'. This request has been blocked; the content must be served over HTTPS.

2

Answers


  1. I understand your backend is a SpringBoot application.
    Configure it to listen on HTTPS.
    Check this tutorial for guidance.

    Login or Signup to reply.
  2. You can "give" a https endpoint to your service hosted on an ec2 by putting an application balancer (ALB) in front of the ec2 then having a cloudfront distribution pointing to the ALB.

    Your service would then be reachable via the CloudFront distribution URL, which is https. Note that traffic between CloudFront and ALB will be in plain http.

    You should be able to stay within the AWS free tier as long as you don’t have any crazy traffic in and out of CloudFront/ALB.

    Good luck

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search