From 7f6193e907c655edde751f30179484c382474faa Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Mon, 10 Jul 2023 13:58:38 +0200 Subject: [PATCH] Patched settings for 500mb upload limit --- lib/docker-compose.base.yml | 3 + lib/patch/nginx.settings.limit.conf.template | 81 ++++++++++++++++++++ lib/patch/settings_limit_patch.js | 39 ++++++++++ 3 files changed, 123 insertions(+) create mode 100644 lib/patch/nginx.settings.limit.conf.template create mode 100644 lib/patch/settings_limit_patch.js diff --git a/lib/docker-compose.base.yml b/lib/docker-compose.base.yml index af68577..e9a0fdf 100644 --- a/lib/docker-compose.base.yml +++ b/lib/docker-compose.base.yml @@ -8,6 +8,8 @@ services: container_name: sharelatex volumes: - "${SHARELATEX_DATA_PATH}:/var/lib/sharelatex" + - ../lib/patch/settings_limit_patch.js:/etc/sharelatex/settings.server-pro.js + - ../lib/patch/nginx.settings.limit.conf.template:/etc/nginx/templates/nginx.conf.template ports: - "${SHARELATEX_LISTEN_IP:-127.0.0.1}:${SHARELATEX_PORT:-80}:80" environment: @@ -19,6 +21,7 @@ services: SHARELATEX_MONGO_URL: "${MONGO_URL}" SHARELATEX_REDIS_HOST: "${REDIS_HOST}" V1_HISTORY_URL: "http://sharelatex:3100/api" + MAX_FILE_UPLOAD_SIZE: 524288000 env_file: - ../config/variables.env stop_grace_period: 60s diff --git a/lib/patch/nginx.settings.limit.conf.template b/lib/patch/nginx.settings.limit.conf.template new file mode 100644 index 0000000..907a2f6 --- /dev/null +++ b/lib/patch/nginx.settings.limit.conf.template @@ -0,0 +1,81 @@ +## ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ## +## ! This file was generated from a template ! ## +## ! See /etc/nginx/templates/ ! ## +## ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ## +daemon off; +user www-data; +worker_processes ${NGINX_WORKER_PROCESSES}; +pid /run/nginx.pid; + +events { + worker_connections ${NGINX_WORKER_CONNECTIONS}; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout ${NGINX_KEEPALIVE_TIMEOUT}; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # Logging Settings + ## + + access_log /var/log/nginx/access.log; + error_log /var/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + gzip_disable "msie6"; + gzip_proxied any; # allow upstream server to compress. + + client_max_body_size 500m; + + # 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/x-javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # nginx-naxsi config + ## + # Uncomment it if you installed nginx-naxsi + ## + + #include /etc/nginx/naxsi_core.rules; + + ## + # nginx-passenger config + ## + # Uncomment it if you installed nginx-passenger + ## + + #passenger_root /usr; + #passenger_ruby /usr/bin/ruby; + + ## + # Virtual Host Configs + ## + + include /etc/nginx/conf.d/*.conf; + include /etc/nginx/sites-enabled/*; +} diff --git a/lib/patch/settings_limit_patch.js b/lib/patch/settings_limit_patch.js new file mode 100644 index 0000000..62bc54c --- /dev/null +++ b/lib/patch/settings_limit_patch.js @@ -0,0 +1,39 @@ +/* eslint-disable import/no-absolute-path */ +const Path = require('path') +const base = require('/overleaf/services/web/config/settings.overrides.server-pro') +const settings = require('/etc/sharelatex/settings.js') + +settings.imageRoot = 'quay.io/sharelatex' + +// TeX Live Images +// ----------- +// +if (process.env.SANDBOXED_COMPILES === 'true') { + let allTexLiveDockerImages + if (process.env.ALL_TEX_LIVE_DOCKER_IMAGES != null) { + allTexLiveDockerImages = process.env.ALL_TEX_LIVE_DOCKER_IMAGES.split(',') + } + + let allTexLiveDockerImageNames + if (process.env.ALL_TEX_LIVE_DOCKER_IMAGE_NAMES != null) { + allTexLiveDockerImageNames = + process.env.ALL_TEX_LIVE_DOCKER_IMAGE_NAMES.split(',') + } + + if (allTexLiveDockerImages != null) { + settings.allowedImageNames = [] + for (let index = 0; index < allTexLiveDockerImages.length; index++) { + const fullImageName = allTexLiveDockerImages[index] + const imageName = Path.basename(fullImageName) + const imageDesc = + allTexLiveDockerImageNames != null + ? allTexLiveDockerImageNames[index] + : imageName + settings.allowedImageNames.push({ imageName, imageDesc }) + } + } +} + +settings.maxUploadSize = parseInt(process.env.MAX_FILE_UPLOAD_SIZE, 10) + +module.exports = base.mergeWith(settings)