Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Cloudfront with basic auth?

I am implementing a cloudfront solution and would like to test / run it on my staging server, however staging is "protected" from the outside world by basic_auth.

I have tried entering a URL with the basic_auth username / password in it e.g user:[email protected] but CloudFront rejects this URL.

How can I allow Cloudfront / an origin to access my staging server?

(I am hosting on heroku, using rails 4)

like image 876
Jason Avatar asked Nov 03 '16 16:11

Jason


People also ask

How do I pass basic auth credentials in URL?

We can do HTTP basic authentication URL with @ in password. We have to pass the credentials appended with the URL. The username and password must be added with the format − https://username:password@URL.


1 Answers

Because of the way web content caching works, most HTTP request headers are not forwarded from CloudFront to the origin server by default, including the Authorization header needed for basic auth.

You'll need to whitelist the Authorization header in the appropriate cache behavior(s).

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesWhitelistHeaders

like image 52
Michael - sqlbot Avatar answered Nov 01 '22 07:11

Michael - sqlbot