K
K
Kyubey2017-03-29 18:19:44
Nginx
Kyubey, 2017-03-29 18:19:44

(nginx) How to deny access to folders, but allow to files?

Hello. I have nginx, and it is responsible for the statics on the server, giving the rest to Apache through a proxy pass.
Recently I ran into a problem: you can go to the site at / css (css folder in the static folder) and see a list of files. This is bad behavior, but the only way I was able to solve it was:
location /static/ { deny all; }
Now file listings are not displayed, however, despite the fact that the following rule follows -

location ~* .(jpeg|jpg|...другие типы данных)$ {
root /home/sitename/public_html/;
access_log off;
expires 30d;
}

..the files themselves cannot be retrieved and 403 is issued. The
question is: how can I make it possible to receive files, but not just look into folders?
(The folders are owned by the user. They have read permissions, but they can't write or execute (0644). There must be some easy solution, but the search for a solution turned up no results.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton B, 2017-03-29
@Kyubey

nginx.org/ru/docs/http/ngx_http_autoindex_module.html
autoindex off;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question