Split nginx configuration to several files

This commit is contained in:
Kristóf Tóth 2018-01-31 17:51:45 +01:00
parent 0ec79fe8d0
commit c99630172b
4 changed files with 17 additions and 13 deletions

View File

@ -58,20 +58,24 @@ ENV TFW_TERMINADO_WD="/home/${AVATAO_USER}"
ENV TFW_LIB_DIR="/usr/local/lib/"
ENV TFW_SUPERVISORD_CONF="/etc/supervisor/supervisord.conf"
ENV TFW_SUPERVISORD_COMPONENTS="/etc/supervisor/conf"
ENV TFW_NGINX_CONF="/etc/nginx/sites-enabled/default"
ENV TFW_NGINX_COMPONENTS="/etc/nginx/components"
ENV PYTHONPATH=${TFW_LIB_DIR}
COPY nginx /etc/nginx
COPY lib ${TFW_LIB_DIR}
COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF}
COPY supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS}
COPY nginx/nginx.conf ${TFW_NGINX_CONF}
COPY nginx/components/ ${TFW_NGINX_COMPONENTS}
COPY src/app ${TFW_APP_DIR}
COPY src/event_handlers ${TFW_EVENT_HANDLERS_DIR}
RUN chown -R ${AVATAO_USER}: /var/log/nginx /var/lib/nginx &&\
# nginx runs as a regular user, and can't write to /run
sed -i 's#pid /run/nginx.pid;#pid /tmp/nginx.pid;#g' /etc/nginx/nginx.conf &&\
envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" \
< /etc/nginx/sites-available/default > /etc/nginx/sites-available/default &&\
for f in "${TFW_NGINX_CONF}" ${TFW_NGINX_COMPONENTS}/*.conf; do \
envsubst "$(printenv | cut -d= -f1 | grep TFW_ | sed -e 's/^/$/g')" < $f > $f ;\
done &&\
mv /data/dist ${TFW_FRONTEND_DIR}
USER ${AVATAO_USER}

View File

@ -0,0 +1,3 @@
location = /login {
proxy_pass http://127.0.0.1:${TFW_LOGIN_APP_PORT};
}

View File

@ -0,0 +1,6 @@
location = /terminal {
proxy_pass http://127.0.0.1:${TFW_TERMINADO_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

View File

@ -12,16 +12,7 @@ server {
proxy_set_header Connection "Upgrade";
}
location = /terminal {
proxy_pass http://127.0.0.1:${TFW_TERMINADO_PORT};
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location = /login {
proxy_pass http://127.0.0.1:${TFW_LOGIN_APP_PORT};
}
include ${TFW_NGINX_COMPONENTS}/*.conf;
location / {
root ${TFW_FRONTEND_DIR};