使用基本身份验证密码保护目录
Password protect a directory using basic authentication
我正在尝试为我的网站创建一个受密码保护的目录,到目前为止,我已经按照 apache 的说明进行操作:http://httpd.apache.org/docs/current/howto/auth.html
和
http://wiki.apache.org/httpd/PasswordBasicAuth
然后我使用 htpasswd 创建了一个密码文件,然后我用
编辑了我的 httpd.conf
<Directory /var/www/html/project/app.project.com/Admin/>
AuthType Basic
AuthName "Restricted Area"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "/var/www/html/admin/.password"
Require valid-user
Order allow,deny
Allow from all
</Directory>
但是当我访问应该要求我输入密码的网站时,却没有!
我只是想弄清楚我做错了什么。
谢谢!
我认为与此无关的问题是我试图使用配置文件中的一个虚拟主机访问该受保护的目录,所以我只需要将此目录指令放在对应的虚拟主机中正在访问,这就是我最后获得配置的方式:
# Please note as well that I'm forcing connections from http to https:
<VirtualHost *:80>
ServerName app.project.com
ServerAlias project.com
DocumentRoot /var/www/html/project/app.project.com
Redirect permanent / https://app.project.com
ErrorLog /var/www/html/project/app.project.com/error.log
CustomLog /var/www/html/project/app.project.com/requests.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName app.project.com
DocumentRoot /var/www/html/project/app.project.com
SSLEngine On
SSLCertificateFile /etc/httpd/ssl/40d5d69ae6a53.crt
SSLCertificateKeyFile /etc/httpd/ssl/project.key
SSLCertificateChainFile /etc/httpd/ssl/gd_bundle-g2-g1.crt
#Adding the Directory directive to request auth access with password to the Admin directory
<Directory /var/www/html/project/app.project.com/Admin/>
AuthType Basic
AuthName "Restricted Area"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "/var/www/html/admin/.password"
Require valid-user
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我正在尝试为我的网站创建一个受密码保护的目录,到目前为止,我已经按照 apache 的说明进行操作:http://httpd.apache.org/docs/current/howto/auth.html
和
http://wiki.apache.org/httpd/PasswordBasicAuth
然后我使用 htpasswd 创建了一个密码文件,然后我用
编辑了我的 httpd.conf<Directory /var/www/html/project/app.project.com/Admin/>
AuthType Basic
AuthName "Restricted Area"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "/var/www/html/admin/.password"
Require valid-user
Order allow,deny
Allow from all
</Directory>
但是当我访问应该要求我输入密码的网站时,却没有!
我只是想弄清楚我做错了什么。
谢谢!
我认为与此无关的问题是我试图使用配置文件中的一个虚拟主机访问该受保护的目录,所以我只需要将此目录指令放在对应的虚拟主机中正在访问,这就是我最后获得配置的方式:
# Please note as well that I'm forcing connections from http to https:
<VirtualHost *:80>
ServerName app.project.com
ServerAlias project.com
DocumentRoot /var/www/html/project/app.project.com
Redirect permanent / https://app.project.com
ErrorLog /var/www/html/project/app.project.com/error.log
CustomLog /var/www/html/project/app.project.com/requests.log combined
</VirtualHost>
<VirtualHost *:443>
ServerName app.project.com
DocumentRoot /var/www/html/project/app.project.com
SSLEngine On
SSLCertificateFile /etc/httpd/ssl/40d5d69ae6a53.crt
SSLCertificateKeyFile /etc/httpd/ssl/project.key
SSLCertificateChainFile /etc/httpd/ssl/gd_bundle-g2-g1.crt
#Adding the Directory directive to request auth access with password to the Admin directory
<Directory /var/www/html/project/app.project.com/Admin/>
AuthType Basic
AuthName "Restricted Area"
# (Following line optional)
AuthBasicProvider file
AuthUserFile "/var/www/html/admin/.password"
Require valid-user
Order allow,deny
Allow from all
</Directory>
</VirtualHost>