What is a reverse proxy?
A Reverse Proxy is an intermediary between a public network and a set of private servers; which is responsible for managing service requests from one or more external computers. These work by manipulating HTTP requests that are sent by various computers; in a process in which requests are attended to and at the same time they manipulate the presentation of these services to avoid compromising critical information from the group of private servers where they are requested.
What is Keepalived?
Keepalived offers us a high availability solution through the use of the VRRP protocol. This protocol, designed for L3 of the OSI layer, simulates the presence of a "virtual" router against which the requests are directed, routing the requests over one of the physical routers that provide service in a completely transparent way for the user. In the event of the physical router going down, the transfer of the service to another physical router is negotiated without any loss of service being noted.
Software installation:
Debian and derivatives:
apt-get install nginx keepalivedRed hat and derivatives:
yum install nginx keepalivedWe proceed to the keepalived configuration
Nodo Master:
cat /etc/keepalived/keepalived.conf
global_defs {
lvs_id nginx_DH
}
vrrp_script check_nginx {
script «killall -0 nginx»
interval 2
weight 2
}
vrrp_instance VI_01 {
state MASTER
interface ens192
virtual_router_id 51
priority 101
virtual_ipaddress {
#IP VIRTUAL
192.168.60.166
}
track_script {
check_nginx
}
}Now we must configure the SLAVE node (we can add as many as we want)
cat /etc/keepalived/keepalived.conf
global_defs {
lvs_id nginx_DH
}
ng
vrrp_script check_nginx {
script «killall -0 nginx»
interval 2
weight 2
}
vrrp_instance VI_01 {
state SLAVE
interface ens192
virtual_router_id 51
priority 101
virtual_ipaddress {
#IP VIRTUAL
192.168.60.166
}
track_script {
check_nginx
}
}We configure the upstream and a reverse proxy in NGINX to perform the tests (on both nodes):
/etc/nginx/sites-enabled/reverseproxy
upstream backend_servers {
least_conn;
server 192.168.1.164; #Nodo master
server 192.168.1.165; #Nodo slave
}
server {
listen 80;
server_name red-orbita.com;
location / {
proxy_pass https://sub.red-orbita.com/;
}
}
Iniciamos los servicios en los dos nodos y lo añadimos al inicio
service keepalived start
service nginx start
ystemctl enable keepalived
systemctl enable nginxAll the best.
:wq!
Comments