Answers: <p>I needed to whitelist <code>Host</code>, <code>Origin</code> and <code>Referer</code> in the <code>Whitelist Headers</code> section. </p>
  
  <p>I've had more issues with CloudFront, wrote a blog post about it, maybe someone will find it helpful: <a href="https://medium.com/@justynazet/placing-a-craft-cms-application-behind-the-cloudfront-1602027ff72b" rel="nofollow noreferrer">https://medium.com/@justynazet/placing-a-craft-cms-application-behind-the-cloudfront-1602027ff72b</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-15T19:38:41.467Z
Answers: 2019-07-15T19:38:41.467Z
Answers: Justyna Zet
Answers: <p>As the issue is happening only with <code>/admin</code> URL, this might be related with cookies which are being passed to the backend application's <code>/admin</code> URL.</p>
  
  <p>You may need to check with CraftCMS team (or some other forums) and get the list of cookies which are being used by the <code>/admin</code> URL. You can whitelist those cookies in cloudfront specifically for <code>/admin</code> URL. </p>
  
Answers: CC BY-SA 4.0
Answers: 2019-07-12T17:38:51.343Z
Answers: 2019-07-12T17:38:51.343Z
Answers: Samit
Body: <p>I have a question regarding a redirect (<code>302</code>) that happens when accessing the <code>/admin</code> panel of my Craft CMS application.</p>
  
  <p>I've setup CloudFront for my app that runs on Craft 3. DNS points to CF (CNAME), CF has Elastic Load Balancer (ELB) as a default origin. The ELB is a subdomain on my main domain (for certificates reasons). There is a CNAME set for ELB on the main domain DNS.</p>
  
  <p>Now, when I'm visiting any page on my application, there is no redirection happening (eg. when I go to www.myapp.com/product). Only when I'm visiting the /admin panel, I get redirected to the ELB domain. Eg. I go to www.myapp.com/admin and I get redirected to www.elb-domain.awsloadbalancerdomain.com (ELB's CNAME). </p>
  
  <p>Any of you has any ideas about why this might be happening and how to prevent it?</p>
  
  <p>Thank you in advance!</p>
  
Tags: <dns><amazon-cloudfront>
Title: Cloudfront for ELB, automatic redirection
UserDisplayName: Justyna Zet
ThreadText: # Cloudfront for ELB, automatic redirection
  
  (Asked by: username_0 on 2019-07-07)
  
  I have a question regarding a redirect (`302`) that happens when accessing the `/admin` panel of my Craft CMS application.
  
  I've setup CloudFront for my app that runs on Craft 3. DNS points to CF (CNAME), CF has Elastic Load Balancer (ELB) as a default origin. The ELB is a subdomain on my main domain (for certificates reasons). There is a CNAME set for ELB on the main domain DNS.
  
  Now, when I'm visiting any page on my application, there is no redirection happening (eg. when I go to www.myapp.com/product). Only when I'm visiting the /admin panel, I get redirected to the ELB domain. Eg. I go to www.myapp.com/admin and I get redirected to www.elb-domain.awsloadbalancerdomain.com (ELB's CNAME).
  
  Any of you has any ideas about why this might be happening and how to prevent it?
  
  Thank you in advance!
  
  **Tags:** dns, amazon-cloudfront
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-07-15. Score: 1
  
  I needed to whitelist `Host`, `Origin` and `Referer` in the `Whitelist Headers` section.
  
  I've had more issues with CloudFront, wrote a blog post about it, maybe someone will find it helpful: <https://medium.com/@username_0/placing-a-craft-cms-application-behind-the-cloudfront-1602027ff72b>
  
  
  ---
  
  ### Answer by username_1 on 2019-07-12. Score: 1
  
  As the issue is happening only with `/admin` URL, this might be related with cookies which are being passed to the backend application's `/admin` URL.
  
  You may need to check with CraftCMS team (or some other forums) and get the list of cookies which are being used by the `/admin` URL. You can whitelist those cookies in cloudfront specifically for `/admin` URL.
  
  
  ---
  
  