我将Nginx设置为可以运行go应用程序,并且我想将auth_basic功能应用于/ login路径。我尝试将auth_basic应用于根路径,但是在提供凭据后,所有应用程序对加载数据的进一步请求均被拒绝。并且我尝试将auth_basic添加到/路径,同时将基本auth保留在登录路径上,但未成功。 这是代码。
server {
listen 80 default_server;
server_name example.com;
ssl on;
ssl_certificate server.crt;
ssl_certificate_key private.key;
ssl_stapling on;
ssl_stapling_verify on;
location / {
proxy_pass http://127.0.0.1:8080;
auth_basic off;
}
location /login {
proxy_pass http://127.0.0.1:8080/;
auth_basic "Restricted";
auth_basic_user_file /path/.htpasswd;
}
}