【发布时间】:2010-11-11 08:57:38
【问题描述】:
我设置了一个私人网站,只有少数人可以通过互联网访问该网站。我想设置基本身份验证和 https 的组合。
到目前为止,如果我直接输入https://blah.com/location1,一切正常。但是 我需要 是让 apache 将 http://blah.com/location1 重定向到 https://blah.com/location1 然后进行基本身份验证,即我不希望在重定向之前完成基本身份验证。目前,这就是我的 apache 配置中的内容。
WSGIScriptAlias /site /path/to/site/apache/site.wsgi
<Directory /path/to/site/apache>
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
<Location /site>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
AuthType Basic
AuthName "Site login"
AuthUserFile /path/to/site/.htpasswd
Require valid-user
</Location>
注意:我只需要/site的认证。所以我应该能够访问http://blah.com/site1,http://blah.com/site2,而无需身份验证。
【问题讨论】:
-
一个问题,为什么要使用 https 进行基本身份验证?使用基本身份验证,用户凭据将以纯文本形式发送。
-
这就是为什么我需要从
https而不是http进行基本身份验证。这样它们就会被加密发送 -
我认为你应该将
AuthType Basic ..从 http 配置转移到 https,这意味着两个单独的配置
标签: apache https basic-authentication