0
votes

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>

To summarize I need to have a password protection on the website with .htaccess but I also need cloudfront to go through without disable the whole protection.

Do you have any ideas?

PS: I have done new tests (it works on localhost with MAMP), I have also deleted the behaviours of my CloudFront and test the solution of Amit but nothing change, the prompt doesn't show up.

1
Try removing ^ and $ from the SetEnvIf line.Amit Verma
Unfortunately it doesn't change anything, the poppin still doesn't show upManu

1 Answers

0
votes

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