Answer the question
In order to leave comments, you need to log in
Why does Nginx (in docker-compose) not balance, then balance, then not again? How to fix?
docker-compose.yaml
service: ...
nginx:
image: nginx
env_file:
- .env
depends_on:
- api
- backend1
- backend2
- backend3
- backend4
volumes:
- ./config/nginx.conf:/etc/nginx/conf.d/default.conf
ports:
- ${NGINX_PORT_1}:${NGINX_PORT_1}
- ${NGINX_PORT_2}:${NGINX_PORT_2}
- ${NGINX_PORT_3}:${NGINX_PORT_3}
restart: always
worker_processes auto;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
upstream load1{
server backend1:8001;
server backend2:8001;
}
upstream load2 {
server backend3:8001;
server backend4:8001;
}
access_log /var/log/nginx/access.log;
server {
listen 8558 http2;
charset utf-8;
location / {
grpc_pass grpc://load1;
}
}
server {
listen 8556 http2;
charset utf-8;
location / {
grpc_pass grpc://load2;
}
}
server {
listen 8557;
charset utf-8;
location /api {
proxy_pass http://api:8000;
}
location /nginx_status {
stub_status on;
access_log off;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question