We want to forward all requests to
domain.com/foo to a S3 Bucket fronted by Cloudfront. The idea being that our domain is used while the content is loaded from S3/Cloudfront. I have Apache setup to reverse proxy requests to
<Location /foo> RequestHeader set X-Forwarded-Proto "https" ProxyPassReverseCookiePath / /foo ProxyPass http://bar.cloudfront.net/ ProxyPassReverse http://bar.cloudfront.net/ </Location>
However when I hit
domain.com/foo I get a
403 Forbidden from Cloudfront.
I tried adding the header
RequestHeader set Host "bar.cloudfront.net", the page loads and I see the content in the
s3 bucket, but then the domain is obviously the CDN domain.
I swapped out the cloudfront URL in the Apache config for the s3 bucket's public URL and it worked, while preserving the hostname. So I believe this confirms its an issue with Cloudfront.
I added our domain name as a CNAME on CloudFront. Then set the
RequestHeader set Host to our domain name with the
/foo. This preserves the host name but causes a
400 error from CloudFront.