#!/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 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'}" envsubst '$BACKEND_HOST $BACKEND_PORT $GZIP_BLOCK $REAL_IP_BLOCK $FRONTEND_PORT $NGINX_CLIENT_MAX_BODY_SIZE' \ < /etc/nginx/templates/default.conf.template \ > /etc/nginx/conf.d/default.conf exec nginx -g 'daemon off;'