1
resposta

[Sugestão] Versão com container

load balance

root@f86531f48431:/etc/nginx/conf.d# ls
default.origin  load_balance.conf  server1.conf  server2.conf  server3.conf
root@f86531f48431:/etc/nginx/conf.d# cat server1.conf 
server {
  listen 80;
  server_name localhost;
  location / {
    root /home/html1;
    index index.html;
  }
  location /srvc2 {
    proxy_pass http://localhost:8002/;
  }
  location /srvc3 {
    proxy_pass http://localhost:8003/;
  }
  location /srvc4 {
    proxy_pass http://localhost:8004/;
  }
  error_page 404 400 401 /error4xx.html;
}
root@f86531f48431:/etc/nginx/conf.d# cat load_balance.conf 
upstream services{
  server localhost:8002;
  server localhost:8003;
}
server {
  listen 8004;
  server_name localhost;
  location / {
    proxy_pass http://services;
  }
}
root@f86531f48431:/etc/nginx/conf.d# cat server2.conf 
server {
  listen 8002;
  server_name localhost;
  location / {
    root /home/html2;
    index index.html;
  }
}
root@f86531f48431:/etc/nginx/conf.d# cat server3.conf 
server {
  listen 8003;
  server_name localhost;
  location / {
    root /home/html3;
    index index.html;
  }
}
1 resposta

Oi, Marcio. Como vai?

Obrigada por compartilhar sua sugestão.

Gostei de ver como organizou seus arquivos de configuração no NGINX, isso mostra um bom controle de ambientes para balanceamento de carga.

Continue postando suas sugestões, elas eriquecem a comunidade.

Alura Conte com o apoio da comunidade Alura na sua jornada. Abraços e bons estudos!