nginx vhosts as a plugin?

This commit is contained in:
Jeff Lindsay
2013-06-30 11:39:05 -05:00
parent 51dc343630
commit c4fd6d620b
7 changed files with 33 additions and 35 deletions

View File

@@ -6,12 +6,7 @@ set -e; case "$1" in
;;
url)
echo "http://$(< "/home/git/$2/HOSTNAME")"
;;
test)
echo "Hello"
echo $2 $3 $4
echo "http://$(< "/home/git/$2/ADDRESS")"
;;
esac

8
plugins/nginx-vhosts/commands Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -e; case "$1" in
url)
echo "http://$(< "/home/git/$2/VHOST")"
;;
esac

View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
APP="$1"; PORT="$2"
if [[ -f "$HOME/VHOST" ]]; then
hostname="${APP/\//-}.$(< "$HOME/VHOST")"
cat<<EOF > $HOME/$APP/nginx.conf
upstream $APP { server 127.0.0.1:$PORT; }
server {
listen 80;
server_name $hostname;
location / { proxy_pass http://$APP; }
}
EOF
nc -U $HOME/reload-nginx
echo "$hostname" > "$HOME/$APP/VHOST"
fi