Created
August 23, 2016 08:41
-
-
Save Sid3y1/c746f8351c35b7c59212f7eded1d49f9 to your computer and use it in GitHub Desktop.
nginx reverse proxy script
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 | |
if [[ ! $3 ]] | |
then | |
echo "Usage ./rproxy.sh name ip port" | |
exit 1 | |
fi | |
if [[ -f /etc/nginx/sites-enabled/$1 ]] | |
then | |
echo "_______________________________________________" | |
echo " " | |
echo " cat /etc/nginx/sites-enabled/$1 " | |
echo "_______________________________________________" | |
cat /etc/nginx/sites-enabled/$1 | |
echo "_______________________________________________" | |
echo " " | |
read -p "Le fichier existe remplacer ? (y/n) " -n 1 -r | |
echo # (optional) move to a new line | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo "File will be overwrited" | |
else | |
echo "Abord" | |
exit 1 | |
fi | |
fi | |
echo " | |
#Automaticaly added by a super script | |
server { | |
listen 80; | |
server_name $1 www.$1; | |
access_log /var/log/nginx/$1.access.log; | |
location / { | |
proxy_pass http://$2:$3/; | |
} | |
} | |
" > /etc/nginx/sites-enabled/$1 | |
/etc/init.d/nginx reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment