Posts

Showing posts from February, 2025

Nginx : Virtual hosting using Location directives

Image
This setup demonstrates a virtual container-based environment in Nginx where multiple locations are configured under a single server block, rather than a load-balancing mechanism. Each location serves a different application based on its respective directory structure. Nginx Configuration Server Configuration server { listen 80; server_tokens off; server_name _; client_max_body_size 35M; charset utf-8; large_client_header_buffers 4 16k; root /usr/share/nginx/server1; index index.html index.php index.cgi; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; location /server2 { root /usr/share/nginx/; index index.html index.php index.cgi; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; } location /server3 { root /usr/share/nginx/; index index.html index.php index.cgi; access_log /var/log/nginx/access.log; error_log /...

Nginx : Setting Up Nginx with Load Balancing

Image
This guide explains how to configure Nginx as a load balancer for multiple backend applications running on different ports. The setup includes three application servers running on ports 8001, 8002, and 8003, with Nginx balancing requests among them.   Nginx Configuration Details Individual Server Blocks Each backend application is configured as an independent Nginx server block: Server 1 Configuration ( server1.conf ) [root@server1 conf.d]# cat /etc/nginx/conf.d/server1.conf | grep -v "#"   server { listen 8001; server_tokens off; server_name _; client_max_body_size 35M; charset utf-8; large_client_header_buffers 4 16k; root /usr/share/nginx/server1; index index.html index.php index.cgi; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; } Server 2 Configuration ( server2.conf ) [root@server1 conf.d]# cat /etc/nginx/conf.d/server2.conf | grep -v "#"     server { listen 8002; server_tokens off;...

DRBD with PCS: Make production at HIGH availability!

Image
  DRBD Configuration with PCS (Pacemaker/Corosync) ---------------------------------------------------------- 1. Introduction DRBD (Distributed Replicated Block Device) is a block-level replication tool that allows real-time data replication between two servers for high availability. When combined with PCS (Pacemaker/Corosync) , it provides automatic failover in case of primary node failure. 2. Understanding DRBD with PCS DRBD replicates data between two servers at the block level. Both servers have an HDD connected via a dedicated cross cable to ensure fast and direct replication. Only one server is Primary at a time, while the other remains Secondary . The Primary node handles read/write operations, while the Secondary node keeps data in sync. In case of failover, the Secondary node becomes Primary, ensuring high availability. The IP address of the cross cable connection is mentioned in /etc/drbd.d/drbd0.res , allowing...