Skip to content

Instantly share code, notes, and snippets.

@changx03
Last active May 18, 2019 18:13
Show Gist options
  • Save changx03/b56e61c70ec29ee403ff5860e51091ee to your computer and use it in GitHub Desktop.
Save changx03/b56e61c70ec29ee403ff5860e51091ee to your computer and use it in GitHub Desktop.
For running nginx load balancer
# -*- mode: ruby -*-
# vi: set ft=ruby :
# `vagrant ssh lb1` to shh on one machine
# `vagrant up web2` to start one machine
# `free -m` check memory size
# `ifconfig` check ip address
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end
# load balancer 1
config.vm.define "lb1" do |lb1|
lb1.vm.box = "ubuntu/xenial64"
lb1.vm.network "private_network", ip: "10.0.0.10"
lb1.vm.provision "shell" do |s|
s.args = ["lb1"]
s.path = "https://gist.githubusercontent.com/changx03/bc23828b1ed1e140e491788bdc24a3ba/raw/7f87b7ae339e8fa21a7fd9578c521186001b25d9/provision_lb1.sh"
end
end
# load ba lancer 1
config.vm.define "web1" do |web1|
web1.vm.box = "ubuntu/xenial64"
web1.vm.network "private_network", ip: "10.0.0.11"
web1.vm.provision "shell" do |s|
s.args = ["web1"]
s.path = "https://gist.githubusercontent.com/changx03/2929828f24787735e74a10f0b10ac404/raw/c2af07c2ff6355f047f23ed1bca02b16401d7f6f/provision_web.sh"
end
end
# load balancer 3
config.vm.define "web2" do |web2|
web2.vm.box = "ubuntu/xenial64"
web2.vm.network "private_network", ip: "10.0.0.12"
web2.vm.provision "shell" do |s|
s.args = ["web2"]
s.path = "https://gist.githubusercontent.com/changx03/2929828f24787735e74a10f0b10ac404/raw/c2af07c2ff6355f047f23ed1bca02b16401d7f6f/provision_web.sh"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment