homeos/docker/nginx/default.conf

69 lines
2.1 KiB
Plaintext

# WebSocket upgrade mapping (http context)
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/html/public;
index index.php;
charset utf-8;
client_max_body_size 32M;
# Reverb (Pusher protocol) proxied same-origin: browser connects to /app/<key>,
# Laravel publishes to /apps/<id>/events. Keeps WS on the page's own host/port.
# Docker embedded DNS + variable proxy_pass → runtime resolution (reverb may start
# after nginx, or change IP on restart, without breaking the config).
location ~ ^/(app|apps)(/|$) {
resolver 127.0.0.11 valid=30s ipv6=off;
set $reverb_upstream reverb;
proxy_pass http://$reverb_upstream:8080$request_uri;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PWA: correct manifest MIME, and keep the service worker un-cached so updates ship.
location = /manifest.webmanifest {
types { }
default_type application/manifest+json;
add_header Cache-Control "public, max-age=3600";
access_log off;
}
location = /sw.js {
add_header Cache-Control "no-cache";
add_header Service-Worker-Allowed "/";
}
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;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_read_timeout 120s;
}
location ~ /\.(?!well-known).* {
deny all;
}
}