Last active
June 26, 2017 08:37
-
-
Save dragoljub-bogicevic-devtech/08411419c04def175d612d66a1596850 to your computer and use it in GitHub Desktop.
Set up nginx as reverse proxy for two php-fpm web-servers
This file contains 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: reverse proxy' | |
sudo apt-get update | |
sudo apt-get install -y nginx | |
sudo service nginx stop | |
sudo mkdir -p /var/www/html | |
sudo touch /var/www/html/index.html | |
echo '<html><body><a href="http://proxy.dev/app1">APP1</a><br><br> | |
<a href="http://proxy.dev/app2">APP2</a><br><br> | |
</body></html>' >> /var/www/html/index.html | |
sudo rm -rf /etc/nginx/sites-available/default | |
sudo rm -rf /etc/nginx/sites-enabled/default | |
sudo touch /etc/nginx/sites-enabled/default | |
echo "server { | |
listen 80 default_server; | |
root /var/www/html; | |
index index.html index.htm; | |
server_name proxy.dev www.proxy.dev; | |
location / { | |
# try_files $uri $uri/ =404; | |
} | |
location /app1/ { | |
rewrite ^/app1(.*) /$1 break; | |
proxy_pass http://192.168.5.6; | |
} | |
location /app2/ { | |
rewrite ^/app2(.*) /$1 break; | |
proxy_pass http://192.168.5.7; | |
} | |
}" >> /etc/nginx/sites-enabled/default | |
sudo service nginx start | |
echo "Machine: reverse proxy" >> /etc/nginx/sites-enabled/default | |
echo '*************** Provision reverse proxy complete ***************' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment