review issues by @progrium
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
APP="$1"; PORT="$2"
|
APP="$1"; PORT="$2"
|
||||||
SSL="$HOME/$APP/ssl"
|
SSL="$HOME/$APP/ssl"
|
||||||
|
|
||||||
if [[ -f "$HOME/VHOST" ]]; then
|
if [[ -f "$HOME/VHOST" ]]; then
|
||||||
VHOST=$(< "$HOME/VHOST")
|
VHOST=$(< "$HOME/VHOST")
|
||||||
SUBDOMAIN=${APP/%\.${VHOST}/}
|
SUBDOMAIN=${APP/%\.${VHOST}/}
|
||||||
@@ -11,51 +12,54 @@ if [[ -f "$HOME/VHOST" ]]; then
|
|||||||
hostname="${APP/\//-}.$VHOST"
|
hostname="${APP/\//-}.$VHOST"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# ssl based nginx.conf
|
||||||
if [[ -f "$SSL/server.crt" ]] && [[ -f "$SSL/server.key" ]]; then
|
if [[ -f "$SSL/server.crt" ]] && [[ -f "$SSL/server.key" ]]; then
|
||||||
CONF='upstream '$APP' { server 127.0.0.1:'$PORT'; }
|
cat<<EOF > $HOME/$APP/nginx.conf
|
||||||
|
upstream $APP { server 127.0.0.1:$PORT; }
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name '$hostname';
|
server_name $hostname;
|
||||||
return 301 https://$host$request_uri;
|
return 301 https://\$host\$request_uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443;
|
listen 443;
|
||||||
server_name '$hostname';
|
server_name $hostname;
|
||||||
|
|
||||||
ssl on;
|
ssl on;
|
||||||
ssl_certificate '$SSL'/server.crt;
|
ssl_certificate $SSL/server.crt;
|
||||||
ssl_certificate_key '$SSL'/server.key;
|
ssl_certificate_key $SSL/server.key;
|
||||||
ssl_ciphers ECDHE-RSA-RC4-SHA;
|
ssl_ciphers ECDHE-RSA-RC4-SHA;
|
||||||
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
|
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
|
||||||
ssl_prefer_server_ciphers on;
|
ssl_prefer_server_ciphers on;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://'$APP';
|
proxy_pass http://$APP;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade \$http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host \$http_host;
|
||||||
proxy_set_header X-Scheme $scheme;
|
proxy_set_header X-Scheme \$scheme;
|
||||||
}
|
}
|
||||||
}'
|
}
|
||||||
|
EOF
|
||||||
else
|
else
|
||||||
CONF='upstream '$APP' { server 127.0.0.1:'$PORT'; }
|
# default nginx.conf
|
||||||
|
cat<<EOF > $HOME/$APP/nginx.conf
|
||||||
|
upstream $APP { server 127.0.0.1:$PORT; }
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name '$hostname';
|
server_name $hostname;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://'$APP';
|
proxy_pass http://$APP;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
proxy_set_header Upgrade \$http_upgrade;
|
||||||
proxy_set_header Connection "upgrade";
|
proxy_set_header Connection "upgrade";
|
||||||
proxy_set_header Host $http_host;
|
proxy_set_header Host \$http_host;
|
||||||
}
|
}
|
||||||
}'
|
}
|
||||||
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$CONF" > $HOME/$APP/nginx.conf
|
|
||||||
nc -U $HOME/reload-nginx
|
nc -U $HOME/reload-nginx
|
||||||
echo "$hostname" > "$HOME/$APP/VHOST"
|
echo "$hostname" > "$HOME/$APP/VHOST"
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user