fix nginx on docker dev

This commit is contained in:
sadnub 2021-09-06 12:54:37 -04:00
parent 7556197485
commit 6facf6a324
2 changed files with 31 additions and 6 deletions

View File

@ -210,6 +210,7 @@ services:
APP_PORT: ${APP_PORT}
API_PORT: ${API_PORT}
API_PROTOCOL: ${API_PROTOCOL}
DEV: 1
networks:
dev:
ipv4_address: ${DOCKER_NGINX_IP}

View File

@ -5,7 +5,7 @@ set -e
: "${WORKER_CONNECTIONS:=2048}"
: "${APP_PORT:=80}"
: "${API_PORT:=80}"
: "${API_PROTOCOL:=}" # blank for uwgsi
: "${DEV:=0}"
CERT_PRIV_PATH=${TACTICAL_DIR}/certs/privkey.pem
CERT_PUB_PATH=${TACTICAL_DIR}/certs/fullchain.pem
@ -29,6 +29,34 @@ fi
/bin/bash -c "sed -i 's/worker_connections.*/worker_connections ${WORKER_CONNECTIONS};/g' /etc/nginx/nginx.conf"
if [ $DEV -eq 1 ]; then
API_NGINX="
#Using variable to disable start checks
set \$api http://tactical-backend:${API_PORT};
proxy_pass \$api;
proxy_http_version 1.1;
proxy_cache_bypass \$http_upgrade;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \"upgrade\";
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header X-Forwarded-Host \$host;
proxy_set_header X-Forwarded-Port \$server_port;
"
else
API_NGINX="
#Using variable to disable start checks
set \$api tactical-backend:${API_PORT};
include uwsgi_params;
uwsgi_pass \$api;
"
fi
nginx_config="$(cat << EOF
# backend config
server {
@ -37,11 +65,7 @@ server {
server_name ${API_HOST};
location / {
#Using variable to disable start checks
set \$api ${API_PROTOCOL}tactical-backend:${API_PORT};
include uwsgi_params;
uwsgi_pass \$api;
${API_NGINX}
}
location /static/ {