Search code examples
.htaccessnginxreverse-proxy

Nginx reverse proxy disable listing directories - autoindex


I have a reverse nginx proxy

   location / {
         autoindex off;
         proxy_set_header HOST $host;
         proxy_set_header X-Forwarded-Proto $scheme;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_pass http://owncloud/;
    }

Now I want to prevent that users can go to https://url.tld/data and view the folder content... autoindex off; is not working.

I want to achieve this without changing the (owncloud) .htaccess because it's inside a docker container.

In which way is this possible?


Solution

  • I Solved it (thanks to @Doon) by blocking the access to the /data directory.

    location /data {
         deny all;
         return 403;
    }
    

    You have to return 403 -> Forbidden (not 404) to pass the owncloud access test.