Regex NGINX基本身份验证,代理内容的位置问题

Regex NGINX基本身份验证,代理内容的位置问题,regex,nginx,basic-authentication,nginx-location,Regex,Nginx,Basic Authentication,Nginx Location,任务是阻止以下内容:/api/ldap adapter/swagger-ui.html 在NGINX default.conf中,我们已经使用了以下位置: location ~ /api(?<p_uri>.*) { #https://serverfault.com/questions/240476/how-to-force-nginx-to-resolve-dns-of-a-dynamic-hostname-everytime-when-doing-p set $ga

任务是阻止以下内容:/api/ldap adapter/swagger-ui.html 在NGINX default.conf中,我们已经使用了以下位置:

location ~ /api(?<p_uri>.*) {
    #https://serverfault.com/questions/240476/how-to-force-nginx-to-resolve-dns-of-a-dynamic-hostname-everytime-when-doing-p
    set $gateway "http://tasks.gateway:8050";
    proxy_pass $gateway$p_uri?$args;
    proxy_intercept_errors on;
    proxy_redirect off;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
精确匹配:

location = /api/ldap-adapter/swagger-ui.html {
        auth_basic           "Administrator’s Area";
        auth_basic_user_file /etc/nginx/conf.d/.htpasswd;
我有以下错误:

2019/12/20 10:41:18 [error] 39#39: *39 open() "/usr/share/nginx/html/api/ldap-adapter/swagger-ui.html" failed (2: No such file or directory), client: 10.255.0.5, server: localhost, request: "GET /api/ldap-adapter/swagger-ui.html HTTP/1.1", 
Nginx使用一些默认的位置前缀:/usr/share/Nginx/html


例如,如何使用swagger ui阻止所有内容?

必须完成
位置
阻止。您需要将
proxy
语句复制到新的
location
块中,否则,Nginx将尝试从其默认根目录提供静态文件。我这样做了,但我又得到了404。我应该如何定义位置?位置~/api(?.swagger ui*)?
location
块必须完整。您需要将
proxy
语句复制到新的
location
块中,否则,Nginx将尝试从其默认根目录提供静态文件。我这样做了,但我又得到了404。我应该如何定义位置?位置~/api(?.swagger ui*)?
2019/12/20 10:41:18 [error] 39#39: *39 open() "/usr/share/nginx/html/api/ldap-adapter/swagger-ui.html" failed (2: No such file or directory), client: 10.255.0.5, server: localhost, request: "GET /api/ldap-adapter/swagger-ui.html HTTP/1.1",