#!/bin/sh set -euo pipefail API_PROXY_PASS_TRIMMED="${API_PROXY_PASS:-}" API_PROXY_PASS_TRIMMED="${API_PROXY_PASS_TRIMMED%%/}" cat <<'BASE' > /etc/nginx/conf.d/default.conf server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; location / { try_files $uri /index.html; } BASE if [ -n "$API_PROXY_PASS_TRIMMED" ]; then cat <> /etc/nginx/conf.d/default.conf location /api/ { proxy_pass ${API_PROXY_PASS_TRIMMED}; 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; } location /download/ { proxy_pass ${API_PROXY_PASS_TRIMMED}; 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 fi cat <<'ENDCFG' >> /etc/nginx/conf.d/default.conf } ENDCFG exec "$@"