首页 > 代码库 > nginx配置网站所有目录下文件http认证
nginx配置网站所有目录下文件http认证
要实现网站所有目录均通过验证才能访问,可将nginx配置文件加为如下内容:
location ^~ / { auth_basic "Authorized users only"; auth_basic_user_file wttxAuth.conf; }
这样访问网站及网站下所有文件均出现提示验证了。
注意,加上认证之后该目录下的PHP将不会被解析,会出现下载提示,如果想可以解析PHP可以将上面的配置改为:
location ^~ / { location ~ .*.(php|php5)?$ { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } auth_basic "Authorized users only"; auth_basic_user_file 这里写前面脚本返回的文件路径; }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。