对2.html页面做授权操作
先进行账号密码的生成 使用 htpasswd -c /etc/nginx/auth_conf 用户名
输入2次密码
(如果没有htpasswd,可以使用yum -y install httpd-tools 进行安装)
然后可使用 more /etc/nginx/auth_conf 查看
接着配置
location ~ ^/2.html { root /opt/app/code; auth_basic 'bobobobobobo'; auth_basic_user_file /etc/nginx/auth_conf; //生成的账号密码位置 index index.html index.htm; }
效果图:
按取消则会出现