John Mark Causing

System Administrator | Hosting Support Engineer

Bacolod City, Philippines

+639393497018

John Mark Causing

System Administrator | Hosting Support Engineer

Bacolod City, Philippines

+639393497018

Our goal is to create a server (Load Balancer) and its IP (just hosts file for localhost testing) is linked to the domains wp1.causingdesigns.net and wp2.causingdesigns.net then it will pass the traffic to LXD server using a reverse proxy then LXD server will forward the traffic to a specific LXC (wp1 or wp2) .

See screenshot for final results:

LB server setup (192.168.50.27)

Nginx configuration reverse proxy passing to LXD server

root@lb:/etc/nginx/sites-enabled# cat wp1.causingdesigns.net 
server {
        listen  80;
        server_name     wp1.causingdesigns.net;
        location / {
                 proxy_pass https://192.168.50.75:80;
		 proxy_set_header Host wp1.causingdesigns.net;
        }
}
root@lb:/etc/nginx/sites-enabled# cat wp2.causingdesigns.net 
server {
        listen  80;
        server_name     wp2.causingdesigns.net;
        location / {
                 proxy_pass https://192.168.50.75:80;
	     	 proxy_set_header Host wp2.causingdesigns.net;
        }
}
root@lb:/etc/nginx/sites-enabled# 

hosts file

127.0.0.1 wp1.causingdesigns.net wp2.causingdesigns.net

LXD server setup (192.168.50.75)

hosts file

192.168.50.27 wp1.causingdesigns.net wp2.causingdesigns.net

lxc command used to add proxy device

 lxc config device add rproxy myport80 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80 proxy_protocol=true

 lxc config device add rproxy myport443 proxy listen=tcp:0.0.0.0:443 connect=tcp:127.0.0.1:443 proxy_protocol=true

LXC “rproxy” setup (10.189.124.75)

/etc/nginx/sites-enabled/wp1.causingdesigns.net

/etc/nginx/sites-enabled/wp2.causingdesigns.net