I have a few websites on a Ubuntu 16.04-Nginx server environment and the Nginx conf file of each includes this set of location blocks:
location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
expires 365d;
}
location / {
index index.php index.html index.htm fastcgi_index;
try_files $uri $uri =404 $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php*-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
This set is the same in all confs and this results in redundancy. I tried to put it inside a server block in the global /etc/nginx/nginx.conf
and restarted the server, but the server crashed.
How can one upstream this set from /etc/nginx/nginx.conf
, into the server block of each site conf?