Cloudfront + Beanstalk + Custom Domain

0

I have a custom domain using route 53.

I have an SSL wildcard for this domain. ( *.example.net )

I have static website with S3 , bucket set to block all puclic access with a cloudfront OAI policy.

I have set up cloudfront, copied the OAI policy to the s3 bucket and set the default root obeject index.html (my static website landing page) Everything is working fine.

Now, I have deployed a flask app using beanstalk, I click on beanstalk env domain and my app is working.

I want to use a subdomain ( myapp.example.net ) from my own domain to load my flask app (beanstalk env domain ). Here is what I have done.

*Created a Cname record myapp.example.net and pasted my cloudfront ID. ** Created a new Origin on my existing cloudfront distribution and set the Origin Domain to my Beanstalk env adress *** Created a new behaviour, set the Path pattern ro myapp.example.net and picked the origin I just created. **** Entered myapp.example.net in Alternate domain names ( in my cloudfront settings )

Now, when I type myapp.example.net on the browser, it loads the index.html file just like typing example.net would do. I was expecting to laod my app which is running under the beanstalk env domain adress.

What am I doing wrong? Do I have to create another Cloudfront distribution for the dynamic app? I have tried a lot of options Amazon Q have giving me, nothing worked.

PS: Aparently it could have been that I had a load balancer set up but I am using a Single instance in Environment type (beanstalk Settings)

thanks a lot, hopefully someone can help me out.

1 Antwort
0

Hello.

Please try deleting the CloudFront cache using the steps in the document below.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

Also, what is the path pattern set in CloudFront?
Isn't this path pattern setting incorrect and accessing S3?

profile picture
EXPERTE
beantwortet vor 2 Monaten
profile picture
EXPERTE
überprüft vor 2 Monaten
  • Thanks for taking the time to look at this. I have done invalidation, but it still did not work. I have triple-checked on the addresses and they are fine. here is a big clue, I swapped the order of the precedence in Behaviours list and now, the opposite is happening. app.example.net is loading my beanstalk domain adress and example.net ( the one which is set up to load s3 bucket ) is also loading my beanstalk adress. Something to do with these precedence order in Behaviours. Does it ring a bell to you?

  • Are you configuring a default root object? Also, there may be a problem with the path pattern, so could you please send me an image? https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/DefaultRootObject.html
    If you have set it, try changing the path pattern as follows.

    Prioritypath patternorigin
    0/default root object file nameS3
    1default(*)Elastic Beanstalk

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen