The root directory shows 404 in nginx

I am new to nginx server. I tried to set a new url "/ images /" for serving images. I edited the bi.site file in the site support folder.

server { listen *:80; access_log /var/log/myproject/access_log; location / { proxy_pass http://127.0.0.1:5000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /images/ { root /www/myproject/files_storage; } } 

And in the directory / www / myproject / files _storage I put the file temp.txt.

When I put http://www.main_url/images/temp.txt , it shows that 404 was not found. What am I doing wrong? Did I miss something important?

+5
source share
1 answer

this is:

 location /images/ { root /www/myproject/files_storage; } 

leads to the path / www / myproject / files _storage / images, it would be obvious if you set error_log. So use the "alias" directive instead of the "root"

http://nginx.org/en/docs/http/ngx_http_core_module.html#alias

+6
source

Source: https://habr.com/ru/post/1211582/


All Articles