docklet/tools/nginx_config.sh

35 lines
876 B
Bash
Raw Normal View History

2017-04-24 23:31:17 +08:00
#!/bin/sh
MASTER_IP=0.0.0.0
NGINX_PORT=8080
PROXY_PORT=8000
WEB_PORT=8888
NGINX_CONF=/etc/nginx
2017-05-08 16:11:47 +08:00
toolsdir=${0%/*}
DOCKLET_TOOLS=$(cd $toolsdir; pwd)
DOCKLET_HOME=${DOCKLET_TOOLS%/*}
DOCKLET_CONF=$DOCKLET_HOME/conf
2017-04-24 23:31:17 +08:00
. $DOCKLET_CONF/docklet.conf
NGINX_CONF=${NGINX_CONF}/sites-enabled
echo "copy nginx_docklet.conf to nginx config path..."
2017-05-08 16:11:47 +08:00
cp $DOCKLET_CONF/nginx_docklet.conf ${NGINX_CONF}/
2017-04-24 23:31:17 +08:00
sed -i "s/%MASTER_IP/${MASTER_IP}/g" ${NGINX_CONF}/nginx_docklet.conf
sed -i "s/%NGINX_PORT/${NGINX_PORT}/g" ${NGINX_CONF}/nginx_docklet.conf
2017-04-24 23:31:17 +08:00
sed -i "s/%PROXY_PORT/${PROXY_PORT}/g" ${NGINX_CONF}/nginx_docklet.conf
sed -i "s/%WEB_PORT/${WEB_PORT}/g" ${NGINX_CONF}/nginx_docklet.conf
2018-12-12 23:26:51 +08:00
if [ "${NGINX_PORT}" != "80" ] && [ "${NGINX_PORT}" != "443" ]
then
sed -i "s/\$host/\$host:\$server_port/g" ${NGINX_CONF}/nginx_docklet.conf
fi
2017-04-24 23:31:17 +08:00
echo "restart nginx..."
/etc/init.d/nginx restart