Nginx基本身份验证问题

时间:2020-06-26 19:20:41

标签: authentication nginx basic-authentication nginx-location nginx-config

我想在nginx中为在URL http://milesblock.com上运行的应用程序配置基本身份验证,该身份会自动更改为http://milesblock.com/#/

现在,问题是,如果我为http://milesblock.com应用基本身份验证,那么它也将应用于下一个后续页面,并陷入无限循环,要求输入用户名和密码,然后一切正常。 我的nginx.conf看起来像这样-

    server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  milesblock.com;


    location / {

       proxy_pass http://127.0.0.1:8090;
       auth_basic "Restricted Area";
       auth_basic_user_file /etc/nginx/.htpasswd;
   }


   location /api1 {

        rewrite ^/api1(.*) $1 break;
        proxy_pass http://127.0.0.1:8000;
    }
}

如何配置nginx,以便仅主URL(http://milesblock.com)仅询问用户名和密码一次?

谢谢!

0 个答案:

没有答案