T
T
timkin12018-07-27 16:49:48
Nginx
timkin1, 2018-07-27 16:49:48

Why files from a directory are not displayed in nginx?

Hello!
I have the following config for nginx:

server {
        listen   443 ssl;
        root /var/www/site;
        index index.html index.htm;
        server_name site;
        ssl_certificate /etc/ssl/certs/site.crt;
        ssl_certificate_key /etc/ssl/private/site.key;

        location /morning/ {
         alias /var/www/site/morning;
         location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf)$ {
             expires 365d;
        }
    }
}

In the morning folder I have pictures, but for some reason if you go to site/morning/photo.png the photo does not open. Tell me, please, what is the problem? Where is the jamb in the config?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
Fixid, 2018-07-27
@timkin1

Show error.log and the absolute path to the image
Or try replacing alias with root
And replace:

location /morning/ {
         alias /var/www/site/morning;
}
         location ~*  \.(jpg|jpeg|png|gif|ico|css|js|ttf)$ {
             alias /var/www/site/morning;
             expires 365d;
        }

K
ky0, 2018-07-27
@ky0

Some strange config. Just nail the aliasfinal slash in the location - everything should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question