Files
3dealer/docker/nginx/prod.conf
T
2026-09-29 17:30:42 +03:00

98 lines
3.0 KiB
Plaintext

upstream php_fpm {
server app:9000;
keepalive 16;
}
server {
listen 80;
server_name _;
root /var/www/html/public;
index index.php;
client_max_body_size 100M;
charset utf-8;
open_file_cache max=5000 inactive=30s;
open_file_cache_valid 60s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
# No FastCGI page cache: every Laravel response is per-visitor (session
# cookie, CSRF token, cart, login state), so a shared cache keyed on the
# URL replays one visitor's page and session cookie to everyone else.
# Vite build assets — content-hashed filenames, safe to cache forever
location /build/ {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
try_files $uri =404;
}
location /static/ {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
try_files $uri =404;
}
location /packages/ {
add_header Cache-Control "public, max-age=31536000, immutable";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
try_files $uri =404;
}
# User media — served directly from the storage volume (no symlink needed)
location /storage/ {
alias /var/www/html/storage/app/public/;
add_header Cache-Control "public, max-age=31536000, immutable";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
try_files $uri =404;
}
location / {
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php_fpm;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_read_timeout 300;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_keep_conn on;
}
location /stoic/ {
proxy_pass http://stoic:2727/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cookie_path / /stoic/;
}
location ~ /\.(?!well-known).* {
deny all;
}
location = /sitemap.xml {
root /var/www/html/storage/app;
try_files /sitemap.xml =404;
add_header Cache-Control "public, max-age=3600";
add_header Content-Type "application/xml; charset=utf-8";
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
}