diff --git a/docker/nginx/conf.d/langbot.conf.template b/docker/nginx/conf.d/langbot.conf.template new file mode 100644 index 0000000000..c81a116137 --- /dev/null +++ b/docker/nginx/conf.d/langbot.conf.template @@ -0,0 +1,24 @@ +# Configuration for langbot.lefeng.school subdomain + +server { + listen ${NGINX_PORT}; + server_name langbot.${NGINX_SERVER_NAME}; + + # Main langbot service + location / { + proxy_pass http://host.docker.internal:5300; + include proxy.conf; + } + + # Callback endpoint + location /callback { + proxy_pass http://host.docker.internal:2290; + include proxy.conf; + } + + # placeholder for acme challenge location + ${ACME_CHALLENGE_LOCATION} + + # placeholder for https config defined in https.conf.template + ${HTTPS_CONFIG} +} \ No newline at end of file diff --git a/docker/nginx/docker-entrypoint.sh b/docker/nginx/docker-entrypoint.sh index 763254e37b..2a4c1c16dd 100755 --- a/docker/nginx/docker-entrypoint.sh +++ b/docker/nginx/docker-entrypoint.sh @@ -19,8 +19,6 @@ if [ "${NGINX_HTTPS_ENABLED}" = "true" ]; then # set the HTTPS_CONFIG environment variable to the content of the https.conf.template HTTPS_CONFIG=$(envsubst < /etc/nginx/https.conf.template) export HTTPS_CONFIG - # Substitute the HTTPS_CONFIG in the default.conf.template with content from https.conf.template - envsubst '${HTTPS_CONFIG}' < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf fi export HTTPS_CONFIG @@ -36,7 +34,13 @@ env_vars=$(printenv | cut -d= -f1 | sed 's/^/$/g' | paste -sd, -) envsubst "$env_vars" < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf envsubst "$env_vars" < /etc/nginx/proxy.conf.template > /etc/nginx/proxy.conf -envsubst "$env_vars" < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf +# Process all template files in conf.d directory +for template in /etc/nginx/conf.d/*.template; do + if [ -f "$template" ]; then + output_file="${template%.template}" + envsubst "$env_vars" < "$template" > "$output_file" + fi +done # Start Nginx using the default entrypoint exec nginx -g 'daemon off;'