perf: add nginx.template.conf with aggressive caching for Nixpacks
This commit is contained in:
52
nginx.template.conf
Normal file
52
nginx.template.conf
Normal file
@@ -0,0 +1,52 @@
|
||||
server {
|
||||
listen ${PORT};
|
||||
server_name _;
|
||||
root /app;
|
||||
index index.php index.html index.htm;
|
||||
|
||||
# GZIP Compression
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_proxied any;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml font/woff2;
|
||||
|
||||
# Browser Caching
|
||||
location ~* \.(jpg|jpeg|png|gif|webp|svg|ico|cur|gz|svgz|mp4|ogg|ogv|webm|htc)$ {
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
location ~* \.(css|js)$ {
|
||||
expires 1M;
|
||||
access_log off;
|
||||
add_header Cache-Control "public, max-age=2592000, immutable";
|
||||
}
|
||||
|
||||
location ~* \.(woff|woff2|ttf|otf|eot)$ {
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
}
|
||||
|
||||
# HTML - Short cache
|
||||
location ~* \.(html|htm)$ {
|
||||
expires 1h;
|
||||
add_header Cache-Control "public, max-age=3600, must-revalidate";
|
||||
}
|
||||
|
||||
# PHP Handling
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html /index.php?$query_string;
|
||||
}
|
||||
|
||||
error_page 404 /404.html;
|
||||
}
|
||||
Reference in New Issue
Block a user