Eu também estou utilizando o HAProxy, mas eu estou querendo fazer alguns testes com o Nginx. Eu encontrei alguns
tutoriais na internet mas até agora nada. O que eu fiz até agora foi:
#: Title : nginx and load balancer
#: Description : Configuracao do NGinx para Load Balance
#: Options : None
INSTALACAO
# instalacao do nginx no debian
#
$ sudo apt-get install nginx -y -d
SYSTEMD
# start/stop/restart
#
$ sudo systemctl stop nginx ; parar o nginx
$ sudo systemctl start nginx ; inicializar o nginx
$ sudo systemctl restart nginx ; reinicializar o nginx
$ sudo systemctl reload nginx ; re-ler a configuracao
$ sudo systemctl enable nginx ; ativar o nginx no boot
$ sudo systemctl status nginx ; status do nginx
# VERIFICACAO
$ ps aux | grep nginx
root 1385 0.0 1.3 91188 3052 ? Ss 09:03 0:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data 1386 0.0 1.5 91556 3740 ? S 09:03 0:00 nginx: worker process
www-data 1388 0.0 1.5 91556 3740 ? S 09:03 0:00 nginx: worker process
www-data 1389 0.0 1.5 91556 3740 ? S 09:03 0:00 nginx: worker process
www-data 1390 0.0 1.5 91556 3740 ? S 09:03 0:00 nginx: worker process
$ netstat -tulpn | grep :80
(No info could be read for "-p": geteuid()=1000 but you should be root.)
tcp6 0 0 :::80 :::* LISTEN -
CONFIGURACAO PADRAO
#
# configuracao do nginx
#
$ sudo ln -s /etc/nginx/sites-available/particula.local /etc/nginx/sites-enabled/particula.local
$ sudo vi /etc/nginx/sites-available/particula.local
server {
listen 80;
server_name particula.local nginxlb.particula.local;
location / {
include /etc/nginx/proxy_params;
}
}
upstream nginxlb {
server web1.particula.local:80;
server web2.particula.local:80;
}