Last active
May 18, 2019 18:11
-
-
Save changx03/bc23828b1ed1e140e491788bdc24a3ba to your computer and use it in GitHub Desktop.
Vagrant provision load balance script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo 'Starting Provision on:' $1 | |
sudo apt-get update | |
sudo apt-get install -y nginx | |
sudo systemctl stop nginx.service | |
sudo rm -rf /etc/nginx/sites-enabled/default | |
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/html; | |
index index.html; | |
# Make site accessible from http://localhost/ | |
server_name localhost; | |
location / { | |
proxy_pass http://testapp; | |
} | |
} | |
" >> /etc/nginx/sites-enabled/default | |
sudo nginx -t | |
sudo systemctl start nginx | |
sudo mkdir -p /var/www/html | |
sudo touch /var/www/html/index.html | |
echo "Machine:" $1 >> /var/www/html/index.html | |
echo "Provision " $1 " completed" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment