From 51dff8c20a31f116c912c1d0a9bc6d511fabf2e2 Mon Sep 17 00:00:00 2001 From: Tao Chen Date: Tue, 17 Mar 2026 22:32:58 +0800 Subject: [PATCH] Git Bridge: support git-bridge configuration via env in nginx - generate overleaf.conf dynamically - support GIT_BRIDGE_HOST and GIT_BRIDGE_PORT - configure client_max_body_size for /git using GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE --- server-ce/Dockerfile | 6 ++++-- .../init_scripts/200_nginx_config_template.sh | 15 +++++++++++++++ .../{overleaf.conf => overleaf.conf.template} | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) rename server-ce/nginx/{overleaf.conf => overleaf.conf.template} (95%) diff --git a/server-ce/Dockerfile b/server-ce/Dockerfile index 8c7d02606b..948b60cbb3 100644 --- a/server-ce/Dockerfile +++ b/server-ce/Dockerfile @@ -47,7 +47,7 @@ ADD server-ce/config/env.sh /etc/overleaf/env.sh # Configure nginx # --------------- ADD server-ce/nginx/nginx.conf.template /etc/nginx/templates/nginx.conf.template -ADD server-ce/nginx/overleaf.conf /etc/nginx/sites-enabled/overleaf.conf +ADD server-ce/nginx/overleaf.conf.template /etc/nginx/templates/overleaf.conf.template ADD server-ce/nginx/clsi-nginx.conf /etc/nginx/sites-enabled/clsi-nginx.conf @@ -119,7 +119,9 @@ ENV GRACEFUL_SHUTDOWN_DELAY_SECONDS=1 ENV NODE_ENV="production" ENV LOG_LEVEL="info" - +ENV GIT_BRIDGE_HOST=git-bridge +ENV GIT_BRIDGE_PORT=8000 +ENV GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE=52428800 EXPOSE 80 ENTRYPOINT ["/sbin/my_init"] diff --git a/server-ce/init_scripts/200_nginx_config_template.sh b/server-ce/init_scripts/200_nginx_config_template.sh index ac908cf511..611fbb997b 100755 --- a/server-ce/init_scripts/200_nginx_config_template.sh +++ b/server-ce/init_scripts/200_nginx_config_template.sh @@ -16,12 +16,18 @@ fi nginx_template_file="${nginx_templates_dir}/nginx.conf.template" nginx_config_file="${nginx_dir}/nginx.conf" +overleaf_template_file="${nginx_templates_dir}/overleaf.conf.template" +overleaf_config_file="${nginx_dir}/sites-enabled/overleaf.conf" + if [ -f "${nginx_template_file}" ]; then export NGINX_KEEPALIVE_TIMEOUT="${NGINX_KEEPALIVE_TIMEOUT:-65}" export NGINX_WORKER_CONNECTIONS="${NGINX_WORKER_CONNECTIONS:-768}" export NGINX_WORKER_PROCESSES="${NGINX_WORKER_PROCESSES:-4}" export MAX_UPLOAD_SIZE="${MAX_UPLOAD_SIZE:-50}" + export GIT_BRIDGE_HOST="${GIT_BRIDGE_HOST:-git-bridge}" + export GIT_BRIDGE_PORT="${GIT_BRIDGE_PORT:-8000}" + export GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE="${GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE:-52428800}" echo "Nginx: generating config file from template" # Note the single-quotes, they are important. @@ -37,6 +43,15 @@ if [ -f "${nginx_template_file}" ]; then < "${nginx_template_file}" \ > "${nginx_config_file}" + # Config git-bridge in nginx + envsubst ' + ${GIT_BRIDGE_HOST} + ${GIT_BRIDGE_PORT} + ${GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE} + ' \ + < "${overleaf_template_file}" \ + > "${overleaf_config_file}" + echo "Checking Nginx config" nginx -t diff --git a/server-ce/nginx/overleaf.conf b/server-ce/nginx/overleaf.conf.template similarity index 95% rename from server-ce/nginx/overleaf.conf rename to server-ce/nginx/overleaf.conf.template index a12088ae59..34ff6357dd 100644 --- a/server-ce/nginx/overleaf.conf +++ b/server-ce/nginx/overleaf.conf.template @@ -24,8 +24,9 @@ server { location ^~ /git/ { resolver_timeout 2s; resolver 127.0.0.11 valid=10s; - set $git_upstream http://git-bridge:8000; + set $git_upstream http://${GIT_BRIDGE_HOST}:${GIT_BRIDGE_PORT}; rewrite ^/git/(.*)$ /$1 break; + client_max_body_size ${GIT_BRIDGE_REPOSTORE_MAX_FILE_SIZE}; proxy_pass $git_upstream; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade;