59 lines
1.7 KiB
Bash
59 lines
1.7 KiB
Bash
#!/usr/bin/env sh
|
|
|
|
if [ "$IS_GZIP" = "1" ]; then
|
|
GZIP_BLOCK='gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_buffers 16 8k;
|
|
gzip_http_version 1.1;
|
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
|
gzip_min_length 1024;'
|
|
else
|
|
GZIP_BLOCK=''
|
|
fi
|
|
export GZIP_BLOCK
|
|
|
|
if [ -n "$TRUSTED_PROXY_CIDR" ]; then
|
|
REAL_IP_BLOCK="set_real_ip_from $TRUSTED_PROXY_CIDR;
|
|
real_ip_header X-Forwarded-For;
|
|
real_ip_recursive on;"
|
|
else
|
|
REAL_IP_BLOCK=""
|
|
fi
|
|
export REAL_IP_BLOCK
|
|
|
|
export SWAGGER_HOST="${SWAGGER_HOST:-swagger}"
|
|
export SWAGGER_PORT="${SWAGGER_PORT:-8080}"
|
|
|
|
export BACKEND_HOST="${BACKEND_HOST:-app}"
|
|
export BACKEND_PORT="${BACKEND_PORT:-9000}"
|
|
|
|
export FRONTEND_PORT="${FRONTEND_PORT:-''}"
|
|
export NGINX_CLIENT_MAX_BODY_SIZE="${NGINX_CLIENT_MAX_BODY_SIZE:-'20m'}"
|
|
|
|
if [ "$ENABLE_API_DOCS" = "1" ]; then
|
|
API_DOCS_BLOCK="location /api-docs {
|
|
proxy_pass http://${SWAGGER_HOST}:${SWAGGER_PORT};
|
|
proxy_set_header HTTP_HOST \$host_with_port;
|
|
proxy_set_header Host \$host_with_port;
|
|
proxy_set_header X-Forwarded-Host \$http_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_redirect off;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
}"
|
|
else
|
|
API_DOCS_BLOCK=""
|
|
fi
|
|
export API_DOCS_BLOCK
|
|
|
|
envsubst '$BACKEND_HOST $BACKEND_PORT $GZIP_BLOCK $REAL_IP_BLOCK $FRONTEND_PORT $NGINX_CLIENT_MAX_BODY_SIZE $API_DOCS_BLOCK' \
|
|
< /etc/nginx/templates/default.conf.template \
|
|
> /etc/nginx/conf.d/default.conf
|
|
|
|
exec nginx -g 'daemon off;'
|