61 lines
1.6 KiB
Nginx Configuration File
61 lines
1.6 KiB
Nginx Configuration File
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
upstream backend_nodes {
|
|
# Round-robin load balancing across all backend nodes
|
|
server backend-node-1:8000 weight=1;
|
|
server backend-node-2:8000 weight=1;
|
|
server backend-node-3:8000 weight=1;
|
|
}
|
|
|
|
server {
|
|
listen 8000;
|
|
server_name localhost;
|
|
|
|
# Health check endpoint (direct response)
|
|
location /health {
|
|
access_log off;
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# Proxy all other requests to backend nodes
|
|
location / {
|
|
proxy_pass http://backend_nodes;
|
|
proxy_http_version 1.1;
|
|
|
|
# Header handling
|
|
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;
|
|
|
|
# Connection settings
|
|
proxy_set_header Connection "";
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
|
|
# Buffering
|
|
proxy_buffering on;
|
|
proxy_buffer_size 4k;
|
|
proxy_buffers 8 4k;
|
|
}
|
|
|
|
# API documentation
|
|
location /docs {
|
|
proxy_pass http://backend_nodes;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
|
|
location /openapi.json {
|
|
proxy_pass http://backend_nodes;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
}
|
|
}
|
|
}
|