Can I disable directory listing for my JFrog Artifactory repository? I used nginx for Artifactory.
Documentation from https://www.jfrog.com/confluence/display/RTF/Configuring+NGINX
I Tried with autoindex off
doesnt work.
My configuration
## 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/$1/$2;
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/$1;
}
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;
}
}
There is no out of the box functionality for disabling directory listing in Artifactory.
The directory listing is created by Artifactory itself and not nginx, this is the reason that setting autoindex
has no effect.
If you wish to block directory listing for a specific repository you can configure nginx to prevent access to the relevant repository URL.