Skip to content

Instantly share code, notes, and snippets.

@elsie-dev
Last active September 25, 2021 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elsie-dev/ae8bf2c22fa1b343e4ade5af3fcd5dae to your computer and use it in GitHub Desktop.
Save elsie-dev/ae8bf2c22fa1b343e4ade5af3fcd5dae to your computer and use it in GitHub Desktop.
#!/bin/bash
echo 'Starting Provision: lb1'
sudo apt-get update
sudo apt-get install -y nginx
sudo service nginx stop
sudo rm -rf /etc/nginx/sites-enabled/default
sudo mkdir /var/www/handy.local
sudo touch /var/www/handy.local/index.html
sudo touch /etc/nginx/sites-enabled/default
echo "upstream testapp {
server 10.0.0.11;
server 10.0.0.12;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/handy.local;
index index.html;
location / {
proxy_pass http://testapp;
}
}" >> /etc/nginx/sites-enabled/default
sudo service nginx start
echo "
<h1>The Load Balancer</h1>
<p>If you see this page, You are in the Load Balancer, Please resfresh to test the other servers</p>
" >> /var/www/handy.local/index.html
sudo service nginx restart
echo 'Provision lb1 complete'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment