File size: 2,763 Bytes
99caad5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
70
71
72
73
# Design example for P1 Linux/Nginx. NOT a tested deployment configuration.
# Place these blocks inside the nginx http context. Replace domain/cert paths.
# Run nginx -t on the target machine and perform an authenticated SSE test.
# Application must trust forwarded headers ONLY from this reverse proxy.
upstream workos_api {
    server 127.0.0.1:8000;
    keepalive 16;
}
server {
    listen 443 ssl;
    server_name workos.example.internal;
    ssl_certificate /etc/workos/tls/server.crt;
    ssl_certificate_key /etc/workos/tls/server.key;
    ssl_protocols TLSv1.2 TLSv1.3;

    client_max_body_size 11m;
    client_body_timeout 15s;
    # Restrict upstream network listeners; the app still enforces exact limits.
    # Avoid default access logs containing query strings and resume cursors.
    # Configure a redacted structured log at the application and ops layers.
    access_log off;

    # Operations endpoint stays private. read_ready also requires ops scope.
    location /health/ {
        allow 127.0.0.1;
        allow ::1;
        deny all;
        proxy_pass http://workos_api;
        proxy_set_header Host $host;
    }
    location = /metrics { deny all; }

    location ~ ^/api/v1/runs/[^/]+/events$ {
        proxy_pass http://workos_api;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Connection "";
        proxy_set_header X-Forwarded-Proto $scheme;
        # Replace any client-supplied forwarding chain at this single edge.
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-User-Id "";
        proxy_set_header X-Tenant-Id "";
        proxy_set_header X-Internal-Authorization "";
        proxy_buffering off;
        proxy_cache off;
        gzip off;
        proxy_connect_timeout 2s;
        proxy_read_timeout 75s;
        proxy_send_timeout 15s;
        send_timeout 30s;
        proxy_next_upstream off;
    }
    location /api/v1/ {
        proxy_pass http://workos_api;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header Connection "";
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header X-User-Id "";
        proxy_set_header X-Tenant-Id "";
        proxy_set_header X-Internal-Authorization "";
        proxy_request_buffering off;
        proxy_connect_timeout 2s;
        # Application enforces 10s regular / 60s upload overall deadlines.
        proxy_read_timeout 65s;
        proxy_send_timeout 15s;
        proxy_next_upstream off;
    }
    # Add a versioned Portal static directory explicitly at deployment time.
    location / { return 404; }
}