D
D
De YURII2016-12-29 13:50:42
Nginx
De YURII, 2016-12-29 13:50:42

How to allow dynamic file to be shown via NGINX?

config

location / {
        
        try_files $uri $uri/ /index.php;
        
        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }       
        
        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }
         
            fastcgi_pass    127.0.0.1:9006;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

The bottom line is that with the help of routes I create a dynamic file, the path of which is for example site.com/path/image.png
but nginx does not allow viewing it in this way, how to overcome this?
my solution is to add in one more location
location /images {
try_files $uri $uri/ /index.php;
expires max;
    }

would that be true?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question