Daniel K
Daniel K

Reputation: 53

Hosting React page on S3 and making REST api calls to server on Elastic Beanstalk

Background

I am trying to deploy a dummy application with React frontend and Django backend interacting via REST api. I have done the following:

So now I can do the following

i.e. each component is up and running

Problem

I am having trouble with:

Would appreciate help with

According to Request a certificate in ACM for Elastic Beanstalk backend, it sounds like I have to use a subdomain and request a certificate for that subdomain, and use Cloud 53 to direct requests to that subdomain to Elastic Beanstalk environment. Would that be the case?

Thank you in advance!

Upvotes: 2

Views: 1990

Answers (1)

Marcin
Marcin

Reputation: 238747

By default EB url will HTTP only. To use HTTPS you need to deploy SSL certificate on your ALB.

In order to do that you need a custom domain, because you can only associated an SSL certificates with domains that you control. Thus, normally you would get a domain (you seem to already have one from godaday). So in this case you can setup a subdomain (e.g. api.my-domian.com) on godady. Then you can use AWS ACM to register a free public SSL certificate for api.my-domian.com.

Once the certificate is verified, using either DNS (easier) or email technique, you deploy it on your ALB using HTTPs listener. Obviously you will need to point api.my-domian.com to the EB's https url. You can also redirect on your ALB http traffic from port 80 to 443 to always use https.

Then in your front-end application you only use https://api.my-domian.com, not the original EB url.

There can be also CORS issues alongside this, so have to be vary of them as well.

Upvotes: 1

Related Questions