map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream oct { server application:9000; } server { listen 80; listen [::]:80; index index.php; server_name _; server_tokens off; root /app/public; charset utf-8; location /index.php { try_files /not_exists @octane; } location /health { add_header Content-Type text/plain; return 200 'alive'; } location /rr-metrics { proxy_pass http://application:9180; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 1200s; } location /app { # WebSocket support proxy_pass http://reverb:8080; proxy_http_version 1.1; # WebSocket headers proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Standard headers proxy_set_header Host $http_host; proxy_set_header Scheme $http_x_forwarded_proto; proxy_set_header X-Real-IP $http_x_real_ip; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; # WebSocket timeouts proxy_read_timeout 86400; proxy_send_timeout 86400; proxy_connect_timeout 60; # Disable buffering for WebSocket proxy_buffering off; proxy_cache off; } location / { try_files $uri $uri/ @octane; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/default.error.log error; error_page 404 /index.php; location @octane { set $suffix ""; if ($uri = /index.php) { set $suffix ?$query_string; } proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header Scheme $http_x_forwarded_proto; proxy_set_header X-Real-IP $http_x_real_ip; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto; proxy_pass http://oct$suffix; } }