我想密码保护我的开发人员子域(dev.example.com),并将主域名公之于众。
我想recursion地做到这一点,以便子域上的任何文件或文件夹将始终提示您进行login。
在Nginxconfiguration文件中,我已经添加了以下内容到我的dev.example.com服务器块(请注意,我有主和子域独立的服务器块):
location ^~ / { auth_basic "Administrator Login"; auth_basic_user_file /home/path/to/.htpasswd; }
在SF上search的时候,我的印象是:标识符使得密码保护recursion,但是没有。
虽然dev.example.com特别提示我进行login,但dev.example.com/folder/不会。
我究竟做错了什么?
为了保护整个子域,这些语句应该出现在现有的 server块中:
server { server_name dev.example.com; auth_basic "Administrator Login"; auth_basic_user_file /home/path/to/.htpasswd; ... }
这应该工作。 确保在完成编辑后重新启动nginx。
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html/subdomain; index index.php index.html index.html server_name dev.example.com;; location ^~ / { auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; } }