Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

binggle's avatar

How can I set separate image folder with nginx from laravel ?

How can I set separate image folder with nginx from laravel ?

I don't want to use laravel for image service.

Instead I want to use nginx for image service.

How can I set nginx for image service with laravel ?

for example , I would like to access https://mydomain.com/images/today/1234.png.

My conf is below.

// nginx-mysite.conf

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
}

location /images/ {
    root /var/html/ ;
    index index.html ;
}

But the https://mydomain.com/images/today/1234.png get 404 error.

How can I fix it ?

Is it bad idea to use nginx for image service ?

0 likes
0 replies

Please or to participate in this conversation.