mercredi 5 février 2020

nginx: how to serve file from a subfolder of root?

My local dev env is configured on nginx as is

server {

    listen 80;

    server_name  project.local;

    root         /var/www/project.local/public;

    charset     utf-8;
    index       index.php index.html index.htm;

    location / {
        try_files   $uri $uri/ /index.php?$query_string;
    }
    location    = /favicon.ico { access_log off; log_not_found off; }
    location    = /robots.txt  { access_log off; log_not_found off; }

    error_page  404 /index.php;
    location ~ \.php$ {
        fastcgi_pass    unix:/run/php/php7.2-fpm.sock;
        fastcgi_index   index.php;
        include         fastcgi_params;

        # Questi due parametri sono fondamentali
        # per le app Laravel
        # =>  https://serverfault.com/a/927619/178670
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param   PATH_INFO $fastcgi_path_info;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

The problem is only about a folder /fonts that is inside the root, at /var/www/project.local/fonts

Note: it's not my code, I inherited it... :( Note 2: it's an old laravel 5.4 project

Actually when the website looks for fonts/some.file I got a 404, but the file is already here.

What should I change in nginx conf to allow serving /fonts/some.file from /var/www/project.local/fonts ?

Why actually is not working?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire