我在 centos 6 上运行 nginx。该域配置为使用 ssl。一些特定的文件夹需要密码保护。如果我用 http 键入 url,浏览器会要求输入用户并通过。如果我使用 https 输入相同的 url,则将显示特定文件夹的索引文件,而无需用户通过。
我在我的域特定的 nginx.conf 文件中有这个:
location /protected_folder {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;
}
如何确保使用 http 和 https 的 url 都受密码保护?
最佳答案
我看到nginx在同一个目录下有两个配置文件:nxingx.conf和snginx.conf。我只需要使用相同的身份验证规则更新 snginx.conf 就可以了。
关于ssl - Nginx 基本身份验证适用于 http 但不适用于 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40189919/