forked from mtusi2026/mtusi2026lab6
42 lines
1.1 KiB
Nginx Configuration File
42 lines
1.1 KiB
Nginx Configuration File
worker_processes auto;
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
access_log /var/log/nginx/access.log;
|
|
sendfile on;
|
|
keepalive_timeout 65;
|
|
client_max_body_size 11m;
|
|
|
|
upstream api_backends {
|
|
least_conn;
|
|
server api1:8080 max_fails=1 fail_timeout=3s;
|
|
server api2:8080 max_fails=1 fail_timeout=3s;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
location / {
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header Connection "";
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_connect_timeout 2s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
proxy_next_upstream error timeout http_502 http_503 http_504;
|
|
proxy_next_upstream_tries 2;
|
|
proxy_pass http://api_backends;
|
|
}
|
|
}
|
|
}
|