im not very experienced with nginx so I am a bit lost with vhost set up. Basically my app, when serving some images serves them via php script this is very simple with apache: look for physical image -> if not found push everything in to index.php with the request string as params. No I am tryingtorun this app on nginx and everything works except the image serving via script (I just get a 404). Here is my vhost for nginx:
server {
listen 80;
server_name ~^(www\.)?(?<sname>.+?).subdomain.domain.com$;
root /var/www/$sname/current/public;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~* \.(jpg|jpeg|gif|png|bmp|ico|pdf|flv|swf|exe|html|htm|txt|css|js) {
add_header Cache-Control public;
add_header Cache-Control must-revalidate;
expires 7d;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_index index.php;
}
location ~ /\.ht {
deny all;
}
}
It seems that it is only looking for the image in a physical location, this works for actual physical images, but not for dynamic ones where they are served vua a script. Any help or guidance is greatly appreciated.
Update: ok so i figured out that if I remove the .jpg from cache controll location, it works, but I still want to set cache headers for those dynamic image requests, so how do I make it run via php and then set the cache header after that?