File size: 3,150 Bytes
0383bfc
 
 
 
 
 
 
 
 
 
 
494a23b
0383bfc
 
494a23b
0383bfc
 
 
494a23b
 
0383bfc
 
 
 
 
494a23b
 
 
 
 
 
 
 
 
 
 
 
 
 
0383bfc
 
494a23b
0383bfc
494a23b
0383bfc
 
494a23b
0383bfc
494a23b
0383bfc
 
 
 
494a23b
 
 
 
 
 
 
 
0383bfc
 
 
494a23b
 
0383bfc
 
494a23b
0383bfc
 
 
494a23b
 
0383bfc
494a23b
0383bfc
 
 
494a23b
 
0383bfc
494a23b
 
 
 
 
 
 
 
 
0383bfc
 
 
 
 
 
494a23b
 
0383bfc
 
494a23b
 
 
 
0383bfc
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /run/nginx/nginx.pid;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" "$http_user_agent"';

    access_log /var/log/nginx/access.log main;
    sendfile on;
    keepalive_timeout 65;

    # Temp paths (writable by non-root)
    client_body_temp_path /run/nginx/client_temp;
    proxy_temp_path       /run/nginx/proxy_temp;
    fastcgi_temp_path     /run/nginx/fastcgi_temp;
    uwsgi_temp_path       /run/nginx/uwsgi_temp;
    scgi_temp_path        /run/nginx/scgi_temp;

    # Gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml;
    gzip_min_length 256;
    gzip_vary on;

    # WebSocket upgrade map (must be before server block)
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      '';
    }

    # Upstreams
    upstream airflow {
        server 127.0.0.1:8080;
        keepalive 4;
    }

    upstream refresh {
        server 127.0.0.1:5000;
        keepalive 2;
    }

    server {
        listen 7860;
        server_name _;
        client_max_body_size 100M;

        # Security headers
        add_header X-Frame-Options SAMEORIGIN always;
        add_header X-Content-Type-Options nosniff always;
        add_header X-XSS-Protection "1; mode=block" always;
        add_header Referrer-Policy strict-origin-when-cross-origin always;

        # ---- Refresh service ----
        location /refresh {
            proxy_pass http://refresh;
            proxy_set_header Host $host;
            proxy_set_header Connection "";
            proxy_http_version 1.1;
            proxy_read_timeout 120s;
        }

        location /config {
            proxy_pass http://refresh;
            proxy_set_header Host $host;
            proxy_set_header Connection "";
            proxy_http_version 1.1;
        }

        location /health {
            proxy_pass http://refresh;
            proxy_set_header Host $host;
            proxy_set_header Connection "";
            proxy_http_version 1.1;
        }

        location /status {
            proxy_pass http://refresh;
            proxy_set_header Host $host;
            proxy_set_header Connection "";
            proxy_http_version 1.1;
        }

        # ---- Airflow webserver ----
        location / {
            proxy_pass http://airflow;
            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_http_version 1.1;
            proxy_set_header Connection "";
            proxy_read_timeout 300s;
            proxy_connect_timeout 75s;

            # WebSocket support (for live log tailing)
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }
    }
}