boring-nginx: ngxproxy: enhanced

This commit is contained in:
Wonderfall 2016-05-30 07:43:10 +02:00
parent 92f840f82b
commit b57b17b921

View File

@ -5,19 +5,39 @@ echo "Welcome to ngxproxy utility."
echo "We're about to create a new vhost." echo "We're about to create a new vhost."
echo "" echo ""
read -p "Name: " NAME while [ "$NAME" == "" ]; do
read -p "Domain: " DOMAIN read -p "Name: " NAME
read -p "Container: " CONTAINER done
while [ "$DOMAIN" == "" ]; do
read -p "Domain: " DOMAIN
done
while [ "$CONTAINER" == "" ]; do
read -p "Container: " CONTAINER
done
read -p "Port (blank means 80): " PORT read -p "Port (blank means 80): " PORT
if [ "$PORT" == "" ]; then
PORT="80"
fi
while [[ "$HTTPS" != "y" && "$HTTPS" != "n" ]]; do while [[ "$HTTPS" != "y" && "$HTTPS" != "n" ]]; do
read -p "HTTPS [y/n]: " HTTPS read -p "HTTPS [y/n]: " HTTPS
done done
if [ "$HTTPS" == "y" ]; then if [ "$HTTPS" == "y" ]; then
read -p "Certificate path: " CERTIFICATE_PATH while [ ! -f "$CERTIFICATE_PATH" ]; do
read -p "Certificate key path: " KEY_PATH read -p "Certificate path: " CERTIFICATE_PATH
done
while [ ! -f "$KEY_PATH" ]; do
read -p "Certificate key path: " KEY_PATH
done
cp /etc/nginx/conf/vhost_https.conf /sites-enabled/${NAME}.conf cp /etc/nginx/conf/vhost_https.conf /sites-enabled/${NAME}.conf
sed -i \ sed -i \
-e "s|<CERTIFICATE_PATH>|${CERTIFICATE_PATH}|g" \ -e "s|<CERTIFICATE_PATH>|${CERTIFICATE_PATH}|g" \
-e "s|<KEY_PATH>|${KEY_PATH}|g" \ -e "s|<KEY_PATH>|${KEY_PATH}|g" \
@ -35,19 +55,20 @@ else
cp /etc/nginx/conf/vhost_http.conf /sites-enabled/${NAME}.conf cp /etc/nginx/conf/vhost_http.conf /sites-enabled/${NAME}.conf
fi fi
while [ "$MAX_BODY_SIZE" == "" ]; do
read -p "Max body size (value in MB, or n): " MAX_BODY_SIZE read -p "Max body size (value in MB, or n): " MAX_BODY_SIZE
done
if [ "$MAX_BODY_SIZE" != "n" ]; then if [ "$MAX_BODY_SIZE" != "n" ]; then
sed -i "s|#client_max_body_size <MAX_BODY_SIZE>|client_max_body_size ${MAX_BODY_SIZE}|g" \ sed -i "s|#client_max_body_size <MAX_BODY_SIZE>|client_max_body_size ${MAX_BODY_SIZE}|g" \
/sites-enabled/${NAME}.conf /sites-enabled/${NAME}.conf
fi fi
sed -i \ sed -i \
-e "s|<DOMAIN>|${DOMAIN}|g" \ -e "s|<DOMAIN>|${DOMAIN}|g" \
-e "s|<CONTAINER>|${CONTAINER}|g" \ -e "s|<CONTAINER>|${CONTAINER}|g" \
-e "s|<PORT>|${PORT}|g" \ -e "s|<PORT>|${PORT}|g" \
/sites-enabled/${NAME}.conf /sites-enabled/${NAME}.conf
echo "" echo ""
echo "It's done : ${NAME}.conf has been generated." echo "It's done : ${NAME}.conf has been generated."