mirror of
https://github.com/DRYTRIX/TimeTracker.git
synced 2026-05-17 18:38:46 -05:00
fix(nginx): use http2 on; and lazy-resolve app upstream in Docker
Switch to the listen + http2 on; form for modern nginx. Add Docker DNS resolver and a variable-based proxy_pass so nginx can start before the app container registers, and apply the same upstream to /socket.io/.
This commit is contained in:
@@ -6,12 +6,17 @@ server {
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
listen 443 ssl;
|
||||
listen [::]:443 ssl;
|
||||
http2 on;
|
||||
|
||||
# Catch-all; optionally set a specific server_name
|
||||
server_name _;
|
||||
|
||||
# Docker embedded DNS; resolve app at request time so nginx can start before app registers
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
set $app_upstream app:8080;
|
||||
|
||||
ssl_certificate /etc/nginx/ssl/cert.pem;
|
||||
ssl_certificate_key /etc/nginx/ssl/key.pem;
|
||||
|
||||
@@ -30,7 +35,7 @@ server {
|
||||
|
||||
# Proxy to application
|
||||
location / {
|
||||
proxy_pass http://app:8080;
|
||||
proxy_pass http://$app_upstream;
|
||||
# Preserve original host including port (e.g., localhost:8443)
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Forwarded-Host $http_host;
|
||||
@@ -46,7 +51,7 @@ server {
|
||||
|
||||
# Socket.IO (WebSocket) endpoint
|
||||
location /socket.io/ {
|
||||
proxy_pass http://app:8080/socket.io/;
|
||||
proxy_pass http://$app_upstream/socket.io/;
|
||||
# WebSocket upgrade headers
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
|
||||
Reference in New Issue
Block a user