Files
AFC-Demo/deploy/nginx/nginx.default.conf.template
T

105 lines
3.5 KiB
Plaintext
Raw Normal View History

2025-10-23 12:22:27 +02:00
server {
listen 80;
server_name ${SERVER_NAME};
root /var/www/html/public;
index index.php;
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# Redirect all HTTP requests to HTTPS (optional, remove if TLS is handled upstream)
# -------------------------------------------------
# return 301 https://$host$request_uri;
# -------------------------------------------------
# Livewire + Laravel routes (must come before static block)
# -------------------------------------------------
# Specific location for livewire.min.js (redirect to non-minified version)
location = /livewire/livewire.min.js {
return 301 /livewire/livewire.js$is_args$args;
}
2025-10-27 11:06:43 +01:00
location ^~ /livewire/ {
try_files $uri /index.php?$query_string;
expires off;
add_header Cache-Control "no-store";
}
2025-10-31 14:28:24 +01:00
location ~ ^/flux/flux(\.min)?\.(js|css)$ {
expires off;
try_files $uri $uri/ /index.php?$query_string;
}
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# Static assets with long caching
# -------------------------------------------------
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff2?|eot|ttf|otf|webp|avif)(\?.*)?$ {
2025-10-23 12:22:27 +02:00
expires 7d;
add_header Cache-Control "public, max-age=604800, immutable";
try_files $uri =404;
2025-10-23 13:05:17 +02:00
access_log off;
2025-10-23 12:22:27 +02:00
}
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# Main Laravel entry point
# -------------------------------------------------
2025-10-23 12:22:27 +02:00
location / {
auth_basic "Restricted Access";
auth_basic_user_file /etc/nginx/.htpasswd;
2025-10-23 12:22:27 +02:00
try_files $uri $uri/ /index.php?$query_string;
}
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# PHP-FPM configuration (matches your Alpine socket setup)
# -------------------------------------------------
2025-10-23 13:05:17 +02:00
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
2025-10-27 12:14:15 +01:00
fastcgi_pass 127.0.0.1:9000; # <-- switch from socket to TCP
2025-10-23 13:05:17 +02:00
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
2025-10-27 11:06:43 +01:00
2025-10-23 13:05:17 +02:00
fastcgi_read_timeout 60s;
fastcgi_buffering on;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
2025-10-24 12:52:01 +02:00
2025-10-27 11:06:43 +01:00
# --- Proxy headers for HTTPS and load balancers ---
fastcgi_param HTTP_X_FORWARDED_PROTO $http_x_forwarded_proto;
fastcgi_param HTTP_X_FORWARDED_HOST $http_host;
fastcgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
# --- Tell PHP it's HTTPS when forwarded ---
set $https_flag "";
if ($http_x_forwarded_proto = "https") { set $https_flag "on"; }
fastcgi_param HTTPS $https_flag;
2025-10-23 13:05:17 +02:00
}
2025-10-23 12:22:27 +02:00
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# Upload limits
# -------------------------------------------------
2025-10-23 12:22:27 +02:00
client_max_body_size 64m;
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# Security headers
# -------------------------------------------------
2025-10-23 12:22:27 +02:00
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
2025-10-27 11:06:43 +01:00
# -------------------------------------------------
# Gzip compression
# -------------------------------------------------
gzip on;
gzip_types
text/plain
text/css
application/json
application/javascript
text/xml
application/xml
application/xml+rss
image/svg+xml;
gzip_min_length 1000;
gzip_proxied any;
gzip_vary on;
}