本文介绍了Amazon Cloudfront和.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我们的开发环境中测试Amazon Cloudfront,该环境受.htaccess/.htpasswd保护.开发服务器上的密码保护也导致所有cloudfront.net资产也受到密码保护.而且没有用户名/密码组合.

I'm testing out Amazon Cloudfront in our 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.

我需要做的是通过在.htaccess保护中戳一些漏洞来允许Cloudfront访问开发服务器.

What I need to do is allow cloudfront to access the dev server by poking some holes in the .htaccess protection.

我可以在此处获得 IP地址的列表,但由于它们可能会发生变化,我想知道是否有人知道更好的方法.

I can get a list of IP addresses here but since they are subject to change, I was wondering if anyone knew of a better way.

很遗憾,我无法删除密码保护.

I cannot remove the password protection unfortunately.

推荐答案

这就是我一直在使用的内容:

Here's what I've been using:

SetEnvIf User-Agent ^Amazon Cloudfront$ cdn
SetEnvIf Host ^static.dev.website.com$ cdn # This could also be a cloudfront.net host

AuthType Basic
AuthName "Dev Site"
AuthUserFile /directory/location/.htpasswd
Require valid-user

Order Deny,Allow
Deny from all
Allow from env=cdn
Satisfy Any

本质上,您需要排除前两行处理的与CloudFront相关的请求,以及 env = cdn 允许行.

Essentially, you need you exclude CloudFront-related requests, which the first two lines handle, in conjunction with the Allow from env=cdn line.

这篇关于Amazon Cloudfront和.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 18:25