map $http_origin $cors_origin { default ""; "https://citrineos.digitribe.fr" "https://citrineos.digitribe.fr"; "http://localhost:3000" "http://localhost:3000"; "http://localhost:3002" "http://localhost:3002"; } server { listen 8080; server_name _; # CORS headers add_header Access-Control-Allow-Origin $cors_origin always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Hasura-Admin-Secret, X-Hasura-Role, X-Hasura-User-Id, X-Hasura-Allowed-Roles, X-Requested-With, Cache-Control" always; add_header Access-Control-Max-Age 3600 always; add_header Access-Control-Allow-Credentials "true" always; # Handle preflight OPTIONS if ($request_method = OPTIONS) { add_header Access-Control-Allow-Origin $cors_origin always; add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always; add_header Access-Control-Allow-Headers "Content-Type, Authorization, X-Hasura-Admin-Secret, X-Hasura-Role, X-Hasura-User-Id, X-Hasura-Allowed-Roles, X-Requested-With, Cache-Control" always; add_header Access-Control-Max-Age 3600 always; add_header Access-Control-Allow-Credentials "true" always; add_header Content-Type "text/plain"; add_header Content-Length 0; return 204; } # Health check location /health { default_type application/json; return 200 '{"status":"ok"}'; } # System config location /data/ocpprouter/systemConfig { default_type application/json; return 200 '{"userPreferences":{"telemetryConsent":false},"ocppRouter":{"networkProfile":"default"}}'; } # GraphQL endpoint - both /v1/graphql and /graphql location ~ ^/v?1?/graphql { proxy_pass http://cariflex-hasura:8080; 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_read_timeout 300; proxy_connect_timeout 60; } # Default - proxy everything to Hasura location / { proxy_pass http://cariflex-hasura:8080; 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_read_timeout 300; proxy_connect_timeout 60; } }