-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgateway.conf
More file actions
executable file
·69 lines (56 loc) · 1.93 KB
/
Copy pathgateway.conf
File metadata and controls
executable file
·69 lines (56 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# /etc/nginx/conf.d/gateway.conf
# Main API gateway. All v1 traffic is routed through the request-validator service.
map $http_authorization $auth_header {
default $http_authorization;
}
map $http_origin $cors_origin {
default "";
"~^http://localhost(:[0-9]+)?$" $http_origin;
"~^http://127.0.0.1(:[0-9]+)?$" $http_origin;
"~^vscode-webview://.+$" $http_origin;
}
map "" $waker_upstream {
default "http://waker:18080";
}
map "" $validator_upstream {
default "http://request-validator:18081";
}
server {
listen 8080;
access_log /dev/stdout;
error_log /dev/stderr;
client_max_body_size 64m;
# DNS for Docker internal hostnames
resolver 127.0.0.11 ipv6=off valid=30s;
# Sane proxy defaults
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 900s;
proxy_send_timeout 900s;
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 Authorization $auth_header;
# Health and debug endpoints
location = /healthz { return 200 "ok\n"; }
location ^~ /debug/ { proxy_pass $waker_upstream; }
# Main API endpoint for all v1 traffic
location /v1/ {
# Add CORS headers for all responses
add_header 'Access-Control-Allow-Origin' $cors_origin always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range,Retry-After' always;
if ($request_method = 'OPTIONS') {
return 204;
}
# Pass all v1 traffic to the validator/router service
proxy_pass $validator_upstream;
}
# Fallback for any other requests
location / {
return 404 '{"error": "Not Found"}';
}
}