fix: nginx

This commit is contained in:
u00lipp
2025-10-27 11:06:43 +01:00
parent bd2099db7c
commit c8d9c1cfd5
3 changed files with 60 additions and 15 deletions
-3
View File
@@ -27,9 +27,6 @@
# Add custom PHP logging configuration # Add custom PHP logging configuration
COPY deploy/php-fpm/zz-logging.ini /etc/php82/conf.d/ COPY deploy/php-fpm/zz-logging.ini /etc/php82/conf.d/
# Create user, dirs, and sockets
RUN addgroup -S web && adduser -S web -G web \
&& mkdir -p /run/nginx /run/php /var/www/html /var/log/supervisor
# Configure PHP-FPM socket # Configure PHP-FPM socket
RUN sed -i 's|^listen = 127\\.0\\.0\\.1:9000|listen = /run/php/php-fpm.sock|' /etc/php82/php-fpm.d/www.conf \ RUN sed -i 's|^listen = 127\\.0\\.0\\.1:9000|listen = /run/php/php-fpm.sock|' /etc/php82/php-fpm.d/www.conf \
+57 -11
View File
@@ -5,42 +5,88 @@ server {
root /var/www/html/public; root /var/www/html/public;
index index.php; index index.php;
# Cache-Control für statische Dateien # -------------------------------------------------
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff2?|eot|ttf|otf|webp|avif)$ { # 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)
# -------------------------------------------------
location ^~ /livewire/ {
try_files $uri /index.php?$query_string;
expires off;
add_header Cache-Control "no-store";
}
# -------------------------------------------------
# Static assets with long caching
# -------------------------------------------------
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff2?|eot|ttf|otf|webp|avif)(\?.*)?$ {
expires 7d; expires 7d;
add_header Cache-Control "public, max-age=604800, immutable"; add_header Cache-Control "public, max-age=604800, immutable";
try_files $uri =404; try_files $uri =404;
access_log off; access_log off;
} }
# Haupt-Entry-Point (Laravel) # -------------------------------------------------
# Main Laravel entry point
# -------------------------------------------------
location / { location / {
try_files $uri $uri/ /index.php?$query_string; try_files $uri $uri/ /index.php?$query_string;
} }
# PHP-FPM Verarbeitung # -------------------------------------------------
# PHP-FPM configuration (matches your Alpine socket setup)
# -------------------------------------------------
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params; include fastcgi_params;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/run/php/php-fpm.sock; # <-- Matches Dockerfile sed change
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_read_timeout 60s; fastcgi_read_timeout 60s;
fastcgi_buffering on; fastcgi_buffering on;
fastcgi_buffers 16 16k; fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k; fastcgi_buffer_size 32k;
# Forward the X-Forwarded-Proto header # --- Proxy headers for HTTPS and load balancers ---
fastcgi_param HTTPS $http_x_forwarded_proto; 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;
} }
# Maximale Client Upload-Größe # -------------------------------------------------
# Upload limits
# -------------------------------------------------
client_max_body_size 64m; client_max_body_size 64m;
# Sicherheits-Header # -------------------------------------------------
# Security headers
# -------------------------------------------------
add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always; add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip-Kompression # -------------------------------------------------
# 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;
} }
+2
View File
@@ -13,6 +13,7 @@ stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0 stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2 stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0 stderr_logfile_maxbytes=0
user=nginx
[program:nginx] [program:nginx]
command=/usr/sbin/nginx -g 'daemon off;' command=/usr/sbin/nginx -g 'daemon off;'
@@ -24,3 +25,4 @@ stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0 stdout_logfile_maxbytes=0
stderr_logfile=/dev/fd/2 stderr_logfile=/dev/fd/2
stderr_logfile_maxbytes=0 stderr_logfile_maxbytes=0
user=nginx