Amend backend port in nginx

This commit is contained in:
2025-07-17 13:00:20 +02:00
parent 80e2924e30
commit 4ccbf959f8

View File

@@ -28,7 +28,7 @@ http {
resolver 127.0.0.11 valid=10s ipv6=off; resolver 127.0.0.11 valid=10s ipv6=off;
upstream backend { upstream backend {
server ${API_HOST}:${API_PORT}; server ${API_HOST}:8080;
} }
server { server {
@@ -56,22 +56,23 @@ http {
access_log off; access_log off;
} }
location ^~ /api/ { location /api/ {
# Proxy to Quarkus proxy_pass http://backend:8080/;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Relay CORS headers from the backend # Headers for both simple and preflight requests
proxy_pass_header Access-Control-Allow-Origin; add_header 'Access-Control-Allow-Origin' '$http_origin' always;
proxy_pass_header Access-Control-Allow-Methods; add_header 'Access-Control-Allow-Credentials' 'true' always;
proxy_pass_header Access-Control-Allow-Headers; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
proxy_pass_header Access-Control-Allow-Credentials; add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type' always;
add_header 'Access-Control-Expose-Headers' 'Authorization' always;
# Handle OPTIONS directly
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
} }
# Cache static assets # Cache static assets