为了安全起见,部署的web内容不想让别人看到,或者为了增强安全性。
部署步骤:
-
首先利用apache的htpasswd功能生成一个用户名和密码:
1
2
|
htpasswd -c
/usr/local/nginx/conf/test
.pass
test
New password:123456
|
2.在nginx配置文件location中添加如下两行:
1
2
3
4
5
6
|
location / {
root
/usr/share
;
index index.php index.html index.htm;
auth_basic
"Authorized users only"
;
auth_basic_user_file conf
/test
.pass;
}
|
本文转自 王家东哥 51CTO博客,原文链接:http://blog.51cto.com/xiaodongge/1878183