-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Fully qualified 301 redirects break Amazon CloudFront reverse proxy caching #29456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Well, if the domain is not detected properly, it probably means that you haven't configured Amazon CloudFront as a trusted proxy (or not properly) and so Symfony does not know your request was for |
For test purposes, I've tried to trust all proxies:
I've tried with both the original HEADER_X_.. constant and the one in the snippet above. I'm facing all the same issues with this configuration. Is there any way I could verify that Symfony trusts the CloudFront proxy now, in order to isolate the problem? |
A quick google search seems to tell me that CloudFront is not setting the header for the forwarded host at all by default, and so that extra config is necessary to make it forward the host. |
@arechsteiner Have you been able to check the CloudFront settings? |
I found the setting, but upon forwarding headers I ran into more issues where my origin server tried to redirect to some non-existent CGI script. I decided to completely abandon the CloudFront reverse-proxy setup as it seems too much effort and I don't have that much traffic on my site. Also the thought of having to trust a multitude of probably changing IP addresses from CloudFront seemed daunting. Overall just too complex for my small operation. I'm running the site normally now and currently this is not an issue for me anymore. |
Thanks for the feedback. 👍 I close here then. |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.2.0
Description
I am caching my Symfony based site through Amazon CloudFront, however I'm running into an issue with Symfony's way of redirecting using a fully qualified URL:
Both the function
redirectToRoute("some_route")
as well as the automatic trailing slash redirect introduced in 4.1 return a 301 response where the "Location" header includes the fully qualified URL instead of just the path.This means that my "origin" Symfony application which runs under
origin.mydomain.com
will return a fully qualified redirect tohttps://origin.mydomain.com/some-route/
.So If someone comes along and requests an URL from
mydomain.com/some-route
they'll get redirected tohttps://origin.mydomain.com/some-route/
instead of/some-route/
which would then resolve to the correct host and protocol like so:https://mydomain.com/some-route/
The end result is that the user ends up on the URL of my origin server instead of being served by the CloudFront domain.
Since there is no mention of this in the docs under How to Configure Symfony to Work behind a Load Balancer or a Reverse Proxy I'm thinking it might be a bug.
The text was updated successfully, but these errors were encountered: