File size: 1,916 Bytes
1a3db60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77f1d1a
1a3db60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# =============================================================================
# KRONECTOR — Nginx Reverse Proxy Configuration
# =============================================================================
# Routes all services behind a single domain:
#   /api/*     → FastAPI   (port 8000)
#   /mlflow/*  → MLflow    (port 5000)
#   /          → Redirect to /api/docs
#
# For HTTPS, add a server block with ssl_certificate directives
# or use Certbot with the nginx plugin.
# =============================================================================

upstream api_backend {
    server api:8000;
}

upstream mlflow_backend {
    server mlflow:5000;
}



server {
    listen 80;
    server_name _;

    # --- 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;

    # --- Default: redirect to API docs ---
    location = / {
        return 302 /api/docs;
    }

    # --- FastAPI ---
    location /api/ {
        proxy_pass http://api_backend/;
        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;

        # Increase timeouts for ML inference (Groq API calls can take a few seconds)
        proxy_read_timeout 120s;
        proxy_connect_timeout 10s;
    }

    # --- MLflow Tracking UI ---
    location /mlflow/ {
        proxy_pass http://mlflow_backend/;
        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;
    }



    # --- Health check for load balancers / uptime monitors ---
    location /health {
        proxy_pass http://api_backend/health;
    }
}