worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
upstream ktransformers {
least_conn;
server 172.16.101.101:8080 max_fails=3 fail_timeout=10000s;
server 172.16.101.102:8080 max_fails=3 fail_timeout=10000s;
server 172.16.101.103:8080 max_fails=3 fail_timeout=10000s;
server 172.16.101.104:8080 max_fails=3 fail_timeout=10000s;
server 172.16.101.105:8080 max_fails=3 fail_timeout=10000s;
}
server {
listen 80;
location /v1 {
proxy_pass http://ktransformers;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 5m;
proxy_connect_timeout 2m;
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_set_header X-Accel-Buffering no;
chunked_transfer_encoding off;
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;
}
}
log_format main '$remote_addr $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'$http_user_agent $http_x_forwarded_for $request_time $upstream_response_time $upstream_addr $upstream_status';
access_log /var/log/nginx/access.log main;
}
⚠️不要直接修改已有的连接,而是新建连接,并且最好不要设置前缀和重命名模型,而是保持原始的模型名称,否则负载均衡可能会失效,所有的请求会落在同一个节点上