S
S
Seva2018-11-05 19:45:23
linux
Seva, 2018-11-05 19:45:23

How to configure NGINX for static files (images)?

There are directories. It contains pictures, and nothing but pictures. You need to give these pictures on a subdomain. I do:

server {
 listen 443;
 ssl on;
 ssl_certificate /root/certificate.crt;
 ssl_certificate_key /root/private.key;
 server_name static.v.by;
 root /root/v/server/storage/images;
 location / { 
  include /etc/nginx/mime.types;
  try_files $uri $uri/ =404;
 }
}

I'm trying to load static.v.by/photo.jpg in the browser - I get 404. The picture is exactly in place, the rights are 777.
What's wrong?
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Morozov, 2018-11-05
@WeRn-rm

Specify a link to the static folder of your project

location /static {
        include  /etc/nginx/mime.types;
        root /home/rm/legionwar.lightning-team.ovh/src;
    }

And there will be a link for example: test.ru/static/photo.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question