matab-panel/scripts/nginx/conf/nginx.conf.template

89 lines
2.4 KiB
Plaintext

worker_processes auto;
error_log logs/error.log warn;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 1000;
reset_timedout_connection on;
client_max_body_size 50M;
client_body_buffer_size 128k;
# Gzip compression
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_vary on;
gzip_proxied any;
gzip_types
text/plain
text/css
text/javascript
application/javascript
application/json
application/xml
image/svg+xml;
# FastCGI connection pool — reuse TCP connections to php-cgi instead of
# opening a new one per request (reduces latency on every PHP request)
upstream php_fpm {
server 127.0.0.1:9001;
keepalive 16;
}
server {
listen 8000;
listen [::]:8000;
server_name localhost 127.0.0.1 ::1;
root "{{PUBLIC_DIR}}";
index index.php;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
# Lightweight health-check endpoint — no PHP, used by warmup script
location = /nginx-health {
access_log off;
return 200 "ok";
add_header Content-Type text/plain;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php_fpm;
fastcgi_index index.php;
fastcgi_read_timeout 120;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_keep_conn on;
fastcgi_buffering on;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
}
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
try_files $uri /index.php?$query_string;
}
location ~ /\.ht { deny all; }
}
}