Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm testing Amazon Cloudfront on a dev environment which is protected by .htaccess/.htpasswd. The password protection on the dev server is causing all of the cloudfront.net assets to be password protected as well. And no username/password combination works (the poppin just keep asking for password again and again). I cannot remove the password protection.

I have see this other topic Amazon Cloudfront and .htaccess with the same request.

When I add this code to mine, the password protection is not displayed.

My .htaccess file:

SetEnvIf User-Agent ^Amazon Cloudfront$ cdn 

ErrorDocument 401 default
AuthName "ACCESS"
AuthUserFile /var/www/html/folder/.htpasswd
AuthType Basic
AuthGroupFile None

<RequireAny>
     Require valid-user
     Require env cdn
</RequireAny>

<Files "healthcheckfile.html">
Allow from all 
Satisfy any
</Files>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
502 views
Welcome To Ask or Share your Answers For Others

1 Answer

Ok I've found a solution.

Go to your Cloudfront behaviors and add the next ones where the webauth hit: Accept-Language Accept-Encoding Authorization

Solution thanks to https://medium.com/@omkar.sonawane/amazon-cloudfront-http-request-headers-authorization-header-22393c624da9


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...