JFrog Artifactory 禁用目录列表

JFrog Artifactory Disable Directory Listing

我可以禁用我的 JFrog Artifactory 存储库的目录列表吗?我将 nginx 用于 Artifactory。

文档来自 https://www.jfrog.com/confluence/display/RTF/Configuring+NGINX

我试过 autoindex off 不起作用。

我的配置

## add ssl entries when https has been set in config
ssl_certificate      /etc/nginx/conf.d/example.pem;
ssl_certificate_key  /etc/nginx/conf.d/example.key;
ssl_session_cache shared:SSL:1m;
ssl_prefer_server_ciphers   on;
## server configuration
server {
    listen 80;
    listen [::]:80;
    server_name ~(?<repo>.+)\.artifactory artifactory;
    return 301  https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name ~(?<repo>.+)\.artifactory artifactory;


    if ($http_x_forwarded_proto = '') {
        set $http_x_forwarded_proto  $scheme;
    }
    ## Application specific logs
    ## access_log /var/log/nginx/jfrog.log timing;
    ## error_log /var/log/nginx/jfrog-error.log;
    rewrite ^/$ /artifactory/webapp/ redirect;
    rewrite ^/artifactory/?(/webapp)?$ /artifactory/webapp/ redirect;
    rewrite ^/(v1|v2)/(.*) /artifactory/api/docker/$repo//;
    chunked_transfer_encoding on;
    client_max_body_size 0;

    location /artifactory/ {
        autoindex off;
        proxy_read_timeout  900;
        proxy_pass_header   Server;
        proxy_cookie_path   ~*^/.* /;
        if ( $request_uri ~ ^/artifactory/(.*)$ ) {
             proxy_pass          http://127.0.0.1:8081/artifactory/;
        }
        index index.py;
        autoindex on;
        proxy_pass          http://127.0.0.1:8081/artifactory/;
        proxy_set_header    X-Artifactory-Override-Base-Url $http_x_forwarded_proto://$host:$server_port/artifactory;
        proxy_set_header    X-Forwarded-Port  $server_port;
        proxy_set_header    X-Forwarded-Proto $http_x_forwarded_proto;
        proxy_set_header    Host              $http_host;
        proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
    }
}

Artifactory 中没有用于禁用目录列表的现成功能。
目录列表是由 Artifactory 自己创建的,而不是 nginx,这就是设置 autoindex 没有效果的原因。
如果您希望阻止特定存储库的目录列表,您可以配置 nginx 以防止访问相关存储库 URL。