Files
dokku/plugins/nginx-vhosts/post-deploy
2013-06-30 23:44:58 +02:00

22 lines
488 B
Bash
Executable File

#!/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;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
EOF
nc -U $HOME/reload-nginx
echo "$hostname" > "$HOME/$APP/VHOST"
fi