Welcome! Log In Create A New Profile

Advanced

Separate location for files served by php-fpm

Palvelin Postmaster via nginx
May 08, 2023 02:50PM
Hi all!

I use php-fpm together with nginx.

My PHP app serves files which have hashed filenames and no filename extension from a specific subdirectory url, e.g /files/hash/31b4ba4a0dc6536201c25e92fe464f85

I would like to be able to set, for example, a separate ’expires’ value to these files with nginx (using a separate location block?). Is that achiavable?

server {
listen 443 ssl http2;
server_name my.site.com;
root /var/www/vhosts/my.site.com/site/;
set $ngspage /index.php?ngspage=$uri$is_args&$args;

# PHP file processing configuration
location ~ [^/]\.php(/|$) {
set $location_name php;
fastcgi_pass php74;
include fastcgi_params;
fastcgi_index index.php;

# Regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;

# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;

# Check that the PHP script exists before passing it
try_files $ngspage $fastcgi_script_name =404;
}
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Separate location for files served by php-fpm

Palvelin Postmaster via nginx May 08, 2023 02:50PM

Re: Separate location for files served by php-fpm

Palvelin Postmaster via nginx May 15, 2023 06:48PM

Re: Separate location for files served by php-fpm

Francis Daly May 15, 2023 08:16PM

Re: Separate location for files served by php-fpm

Palvelin Postmaster via nginx May 19, 2023 12:16AM

Re: Separate location for files served by php-fpm

Francis Daly May 24, 2023 01:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 295
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready