
Host nginx reverse proxy.
sudo apt update
sudo apt -y install nginx
sudo nginx -v
docker run -dit -e SERVER_PORT=5001 -p 5001:5001 -h alb-node01 -u root --name=alb-node01 dbgurum/nginxlb:1.0
docker run -dit -e SERVER_PORT=5002 -p 5002:5002 -h alb-node02 -u root --name=alb-node02 dbgurum/nginxlb:1.0
docker run -dit -e SERVER_PORT=5003 -p 5003:5003 -h alb-node03 -u root --name=alb-node03 dbgurum/nginxlb:1.0
Host nginx reverse proxy 구성.
~$ sudo mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.org
~$ sudo vi /etc/nginx/nginx.conf
events { worker_connections 1024; }
http {
# List of application servers
upstream backend-alb {
server 127.0.0.1:5001;
server 127.0.0.1:5002;
server 127.0.0.1:5003;
}
# Configuration for the server
server {
# Running port
listen 80 default_server;
# Proxying the connections
location / {
proxy_pass http://backend-alb;
}
}
}
~$ sudo systemctl restart nginx.service
~$ sudo systemctl status nginx.service
nginx container reverse proxy 구성.
docker run -d -p 8001:80 --name=proxy-container nginx:1.25.0-alpine
~$ vi nginx.conf
events { worker_connections 1024; }
http {
upstream backend-alb {
server 192.168.56.101:5001;
server 192.168.56.101:5002;
server 192.168.56.101:5003;
}
server {
listen 80 default_server;
location / {
proxy_pass http://backend-alb;
}
}
}
~$ docker cp nginx.conf proxy-container:/etc/nginx/nginx.conf
~$ sudo netstat -nlp | grep 8001
docker restart proxy-container
docker ps | grep proxy
curl localhost:8001