Reputation: 4111
I have a development/staging site which serves all it's images through Amazon Cloudfront and S3.
I am in need of password protecting the website now. Going through cPanel i can successfully do so, but now all my images are coming up blank (401 unauthorised response) on the site as they too require the same password credentials.
How can i get around the issue of serving images through amazon and password protecting the site?
As an alternative i also tried blocking access by IP rather than a password but that gives me the same outcome with a 403 (forbidden) server response on all images
Upvotes: 1
Views: 4000
Reputation: 4111
Got this working with a combination of Michael's suggestion of forwarding all request headers to the origin within amazon aws and declaring the cloudfront environment in my htaccess. Both of these together now work
SetEnvIf User-Agent ^Amazon Cloudfront$ cdn
AuthName "xxxx"
AuthUserFile "/home/xxxxxxx/.htpasswds/public_html/passwd"
AuthType Basic
require valid-user
Order Deny,Allow
Deny from all
Allow from env=cdn
Satisfy Any
Upvotes: 2