Set-up and Maintenance of the Overleaf Extended Community Edition

December 13, 2024 Updated on October 5, 2024

The following document lists the steps that I executed, from top to bottom, to get an instance running of the Overleaf Extended Community Edition (also knows as Overleaf-CEP) based on Overleaf Community Edition 5.x.x. Such an instance was used at the SOFT lab around 2024-2025 to remove many of the restrictions imposed on the free version at overleaf.com, most notably restrictions on collaborative editors. The self-hosted instance ended when the university acquired an Overleaf institutional license.

Certain details regaring the internal configuration of university-owned servers have been removed or modified.

In addition to the specifics below, I have contributed a shorter version to the Overleaf-CEP discussion page.

Self-Hosted Overleaf Installation & Configuration

Initialise Overleaf Community Edition

Follow the instructions to initialise Overleaf via the Overleaf Toolkit. Then, make the following modifications.

  • Edit overleaf-toolkit/config/overleaf.rc. Set the following properties, and make sure that the selected port (e.g., 4242) is not blocked by the firewall.

    OVERLEAF_LISTEN_IP=0.0.0.0
    OVERLEAF_PORT=4242
  • Edit overleaf-toolkit/config/variables.env. Set the following property.

    OVERLEAF_SITE_URL=http://spitter.soft.vub.ac.be:4242
  • Run bin/up (or bin/up -d for detached mode)

  • As a final step, after running through everything else in this document, you can optionally customise Overleaf to SOFT's liking. For more info, see Configuring Overleaf.

    OVERLEAF_APP_NAME="SOFT's Overleaf (Community Edition)"
    OVERLEAF_NAV_TITLE="SOFT's Overleaf"
    OVERLEAF_HEADER_IMAGE_URL="https://soft.vub.ac.be/soft/sites/default/files/new_logo.png"
    OVERLEAF_ADMIN_EMAIL=sam.van.den.vonder@vub.be
    ENABLE_CRON_RESOURCE_DELETION=true

Running for the first time

  1. From the overleaf-toolkit directory, run bin/up.
  2. Go to http://spitter.soft.vub.ac.be:4242/launchpad

Install The LDAP Community Project

There is a community project which adds LDAP support, change tracking, and comments.

Install it as follows.

  1. Outside of the overleaf-toolkit directory (e.g., on the same level) clone the overleaf-cep repo.

    git clone https://github.com/yu-i-i/overleaf-cep ./overleaf-cep

    For a production environment, it is likely that you want to use an official release version of Overleaf CE (+ extended features). At the time of writing the Overleaf CEP repo provides tags that correspond to Overleaf releases which were extended by the Overleaf CEP features. For example, the tag v5.2.1-ext. It is recommended to use these official Overleaf release version rather than the main branch because they are more likely to be stable. When a new version is released, hopefully the Overleaf CEP project will soon tag an image with extended features. Otherwise you can still build from main. To select a release version, just use git checkout:

    git checkout v5.2.1-ext
  2. Build the community docker image which will be used by overleaf.

    cd overleaf-cep/server-ce
    make

    Check the name of the docker image that was stored - it will be printed in the console near the end of the build process. At the time of writing make built a docker image with the name sharelatex/sharelatex:HEAD. You can re-tag this image to correspond what is expected by our configuration of Overlef in the docker-compose.override.yml which will be created in the next step. To retag an image, do this to rename the image to v.5.2.1-ext, which is the current Overleaf CE (+ extended features) version.

    docker tag sharelatex/sharelatex:HEAD sharelatex/sharelatex:v5.2.1-ext
  3. Add a special docker-compose override file overleaf-toolkit/config/docker-compose.override.yml with the following content. Note that sharelatex/sharelatex:v5.2.1-ext corresponds to the name of a docker image that was built/renamed in the previous step.

    services:
     sharelatex:
       image: sharelatex/sharelatex:v5.2.1-ext

Configure the LDAP Community Project

  1. In overleaf-toolkit/config/variables.env edit the following section to enable (unencrypted!) LDAP login.

    
    #################
    ## LDAP for CE ##
    #################
    
    EXTERNAL_AUTH=ldap
    OVERLEAF_LDAP_URL=ldap://soft.vub.ac.be
    # The following two variables will be changed later
    # OVERLEAF_LDAP_STARTTLS=true
    # OVERLEAF_LDAP_TLS_OPTS_CA_PATH=["/etc/ssl/certs/MyCACert.pem"] 
    OVERLEAF_LDAP_SEARCH_BASE=ou=People,dc=vub,dc=ac,dc=be
    OVERLEAF_LDAP_SEARCH_FILTER=(|(uid={{username}})(mail={{username}}))
    OVERLEAF_LDAP_EMAIL_ATT=mail
    OVERLEAF_LDAP_FIRST_NAME_ATT=givenName
    OVERLEAF_LDAP_LAST_NAME_ATT=sn
    OVERLEAF_LDAP_NAME_ATT=cn
    OVERLEAF_LDAP_SEARCH_ATTRIBUTES=["uid", "sn", "givenName", "mail"]
    
    OVERLEAF_LDAP_PLACEHOLDER='Username/email (e.g., SOFT LDAP)'
    
    # Via the following configuration, users svdvonde and dvandeun are an admin
    OVERLEAF_LDAP_ADMIN_SEARCH_BASE=ou=People,dc=vub,dc=ac,dc=be
    OVERLEAF_LDAP_ADMIN_SEARCH_FILTER='(|(&(uid=dvandeun)(uid={{username}}))(&(uid=svdvonde)(uid={{username}})))'
    OVERLEAF_LDAP_ADMIN_DN_PROPERTY=username
    OVERLEAF_LDAP_UPDATE_ADMIN_ON_LOGIN=true
    
    # OVERLEAF_LDAP_CONTACTS_FILTER=(gidNumber={{userProperty}})
    # OVERLEAF_LDAP_CONTACTS_PROPERTY=gidNumber
    # OVERLEAF_LDAP_CONTACTS_NON_LDAP_VALUE='*'
    
    # OVERLEAF_LDAP_BIND_DN=cn=ldap_reader,dc=example,dc=com
    # OVERLEAF_LDAP_BIND_CREDENTIALS=GoodNewsEveryone
    # OVERLEAF_LDAP_UPDATE_USER_DETAILS_ON_LOGIN=true
    

    For configuring admins, see here. At this point, if the SOFT LDAP server has been configured to accept unencrypted connections, then Overleaf LDAP login should work. At the time of writing, SOFT's LDAP is indeed configured like this. Proceed with instructions in order to use LDAPS.

  2. In a new directory called overleaf-certificates (on the same level as overleaf-toolkit and overleaf-cep), run the following command to extract the LDAPS server's certificates:

    openssl s_client -showcerts -verify 5 -connect soft.vub.ac.be:636 < /dev/null |awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/{ if(/BEGIN CERTIFICATE/){a++}; out="cert"a".pem"; print >out}'

    At the time of writing, this generated 4 certificates: cert1.pem, cert2.pem, cert3.pem, cert4.pem.

  3. In overleaf-toolkit/config/docker-compose.override.yml, add a volumes section to copy the certificate from the host system into the docker volume. The syntax is as follows:

    volumes:
      - src/file:dest/path

    This results in the following (for the overleaf user account):

    services:
     sharelatex:
       image: sharelatex/sharelatex:v5.2.1-ext
       volumes:
         - /home/overleaf/overleaf-certificates:/etc/ssl/certs
  4. To enable LDAPS you must set the following flags:

    OVERLEAF_LDAP_URL=ldaps://soft.vub.ac.be
    OVERLEAF_LDAP_STARTTLS=false
    OVERLEAF_LDAP_TLS_OPTS_CA_PATH=["/etc/ssl/certs/cert1.pem","/etc/ssl/certs/cert2.pem","/etc/ssl/certs/cert3.pem","/etc/ssl/certs/cert4.pem"]

Enable LDAP Contacts in Overleaf's Sharing Menu

In overleaf-toolkit/config/variables.env, set the following configuration option. The provided LDAP filter tells the Overleaf application that how to look for the contacts of a user. It's possible to have this filter be specified in a user-specific way (e.g., belonging to the same "group" in LDAP), but at the time of writing SOFT is small enough that we don't need this (and also the LDAP list of users is pretty unorganised). Hence, we use the following LDAP filter.

  • The pattern (& x y z) specifies that all filters x y and z must hold.
  • The filter (objectClass=person) retrieves all contacts with this object class (which is everyone)
  • The filter (mail=*) retrieves all contacts that have the mail attribute set to anything. This captures the case where some contacts do not have a mail attribute, which is required for Overleaf.
  • The filter (sambaAcctFlags=[U]) is a proxy way to check for active accounts [U] and disabled accounts [DU].
OVERLEAF_LDAP_CONTACTS_FILTER=(&(objectClass=person)(mail=*)(sambaAcctFlags=[U]))

Configure SMTP Emails

Set the following flags in overleaf-toolkit/config/variables.env to configure SMTP (see Overleaf's Wiki for details).

OVERLEAF_EMAIL_FROM_ADDRESS="SOFT's Overleaf <XXX>"
# OVERLEAF_EMAIL_REPLY_TO=
OVERLEAF_EMAIL_SMTP_HOST=soft.vub.ac.be
OVERLEAF_EMAIL_SMTP_PORT=587
OVERLEAF_EMAIL_SMTP_SECURE=false
OVERLEAF_EMAIL_SMTP_USER=XXX
OVERLEAF_EMAIL_SMTP_PASS=XXX
# OVERLEAF_EMAIL_SMTP_NAME=
# OVERLEAF_EMAIL_SMTP_LOGGER=false
OVERLEAF_EMAIL_SMTP_TLS_REJECT_UNAUTH=true
OVERLEAF_EMAIL_SMTP_IGNORE_TLS=false
OVERLEAF_CUSTOM_EMAIL_FOOTER="<div>This self-hosted version of Overleaf (Community Edition) is run by the <a href='https://soft.vub.ac.be/'>Software Languages Lab (SOFT)</a> at the Vrije Universiteit Brussel.</div>"

Install Full TexLive

The community-built LDAP image ships with a full TexLive by default. If, for some reason, this changes in the future, then see the instructions to install full Tex Live here: https://github.com/overleaf/toolkit/blob/master/doc/ce-upgrading-texlive.md. I believe this installation is required every time Overleaf CE is updated / upgraded.

Note that there can be issues (Web Archive link) when Overleaf does not yet support the latex Tex Live. In this case, a Reddit user (Web Archive link) suggests to install an older (but compatible) version of Tex Live instead of trying to upgrade Overleaf to the latest version of Tex Live.

Enable Sandboxed Compiles

In overleaf-toolkit/config/variables.env set the following variables:

ALL_TEX_LIVE_DOCKER_IMAGES=texlive/texlive:latest-full,texlive/texlive:TL2023-historic
ALL_TEX_LIVE_DOCKER_IMAGE_NAMES=TeXLive 2024, TeXLive 2023
TEX_LIVE_DOCKER_IMAGE=texlive/texlive:latest-full

In overleaf-toolkit/config/overleaf.rc set the following variables.

SERVER_PRO=true
SIBLING_CONTAINERS_ENABLED=true

When running using rootless docker, also set DOCKER_SOCKET_PATH to a correct value. You can find out the current user's id with id -u (in my case, 1002). Then, typically the socket for a rootless docker is at /run/user/<user id>/docker.sock.

DOCKER_SOCKET_PATH=/run/user/1002/docker.sock

The value of the property TEX_LIVE_DOCKER_IMAGE is stored in the database for every project that is created. That is because on Overleaf.com users can choose which version of TexLive to compile their project with, and updating the setting TEX_LIVE_DOCKER_IMAGE (e.g., when a new version is released) does not force older documents to compile with the new version of TexLive. Self hosted Overleaf users do not have this option to pick their compiler. However, the value is still stored in the database, and if you want to change which image is used to compile projects then you will have to update all existing projects that are stored in the database. To do so, execute bin/mongo. Then, modify the imageName property on all existing projects. For example, the following command will set this property to be texlive/texlive:latest-full.

db.projects.updateMany({}, {$set: { "imageName": "texlive/texlive:latest-full"}})

Publishing with HTTPS to overleaf.soft.vub.ac.be

Follow the instructions in https://github.com/overleaf/toolkit/blob/master/doc/tls-proxy.md. At the time of writing, we did the following:

  1. In overleaf-toolkit/config/overleaf.rc, set:

    OVERLEAF_LISTEN_IP=127.0.0.1
    
    # TLS proxy configuration (optional)
    # See documentation in doc/tls-proxy.md
    NGINX_ENABLED=true
    NGINX_CONFIG_PATH=config/nginx/nginx.conf
    NGINX_HTTP_PORT=80
    
    # Replace these IP addresses with the external IP address of your host
    NGINX_HTTP_LISTEN_IP=134.184.43.156
    NGINX_TLS_LISTEN_IP=134.184.43.156
    TLS_PRIVATE_KEY_PATH=config/nginx/certs/overleaf_key.pem         # SEE NEXT STEP
    TLS_CERTIFICATE_PATH=config/nginx/certs/overleaf_certificate.pem # SEE NEXT STEP
    TLS_PORT=443
  2. Find the paths to the certificates in /etc/nginx/sites-available/overleaf.

  3. Set-up nginx on the host machine. In our case, add a section to the existing nginx config based on the example in https://github.com/overleaf/overleaf/wiki/HTTPS-reverse-proxy-using-Nginx. The technical admin said the ssl_ciphers from Cloudflare did not work out of the box, so we used ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

    server {
       listen 443 ssl;
    
       server_name overleaf.soft.vub.ac.be;
       ssl_certificate /etc/nginx/ssl/nginx.crt;
       ssl_certificate_key /etc/nginx/ssl/nginx.key;
    
       # used cloudflares config, but excluding TLS 1.0 & 1.1
       # https://github.com/cloudflare/sslconfig/blob/master/conf
       ssl_protocols               TLSv1.2 TLSv1.3;
       ssl_ecdh_curve              X25519:P-256:P-384:P-521;
       ssl_ciphers                 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
       ssl_prefer_server_ciphers   on;
    
       # config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security
       # to avoid ssl stripping https://en.wikipedia.org/wiki/SSL_stripping#SSL_stripping
       # https://ssl-config.mozilla.org/#server=nginx
       add_header Strict-Transport-Security "max-age=63072000" always;
    
       server_tokens off;
    
       add_header X-Frame-Options SAMEORIGIN;
    
       add_header X-Content-Type-Options nosniff;
    
       client_max_body_size 50M;
    
       location / {
          proxy_pass http://localhost:4242;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "upgrade";
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_read_timeout 3m;
          proxy_send_timeout 3m;
       }
    }
  4. Edit overleaf-toolkit/config/variables.env and set:

    OVERLEAF_BEHIND_PROXY=true
    OVERLEAF_SECURE_COOKIE=true

Misc

The following resources were helpful when installing/configuring some parts of Overleaf CE:

Maintenance

Install Minor Version Updates of the Overleaf CEP Community Project

The deployment of Overleaf is based on the following community project, which adds LDAP support (and some other features) to Overleaf's Community Edition.

The Overleaf CEP repo provides tags that correspond to Overleaf releases which were extended by the Overleaf CEP features. For example, the tag v5.2.1-ext. It is recommended to use these official Overleaf release version rather than the main branch because they are more likely to be stable. When a new version is released, hopefully the Overleaf CEP project will soon tag an image with extended features. Otherwise you can still build from main.

To update said repository to the latest version, you need to fetch the new code from github, rebuild the docker image, and restart Overleaf. Make sure that you are installing only minor versions, and remember that we are not using Overleaf's official code base for our self-hosted version, so any updates to the Overleaf Community Edition will have to be incorporated into the overleaf-cep project (by its developer). When this project is updated, you can update SOFT's self hosted version as follows.

  1. Update the Docker image.

    cd ~/overleaf-cep
    git fetch --tags --prune --prune-tags
    git checkout v5.3.0-ext-v1
    cd server-ce
    make

    Check which docker image is built by make. Sometimes you will have to re-tag this image to correspond what is expected by our configuration of Overlef in the docker-compose.override.yml. To retag an image, do this:

    docker tag sharelatex/sharelatex:HEAD sharelatex/sharelatex:v5.3.0-ext-v1

    Note: use make, make build-base or make build-community depending on which you need. The Base image generally contains the basic dependencies like wget, plus texlive. It's split out because it's a pretty heavy set of dependencies, and it's nice to not have to rebuild all of that every time.

  2. Modify the image that is used by overleaf by editing ~/overleaf-toolkit/config/docker-compose.override.yml, such that it uses the image that you tagged in the previous steps. E.g., sharelatex/sharelatex:v5.3.0-ext-v1.

  3. docker pull updates for the required TeXLive images. This can take a while, and is automatically performed when starting Overleaf. By doing it beforehand, the service is restarted quicker since it detects that the images are recent enough (this reduces downtime).

    docker pull texlive/texlive:latest-full && docker pull texlive/texlive:TL2024-historic && docker pull texlive/texlive:TL2023-historic
  4. Restart the Overleaf Service.

    cd ~/overleaf-toolkit
    bin/up -d

Install Major Version Updates

There are probably special migration instructions when upgrading major versions of Overleaf (e.g., the current 5.X to the future 6.X). At the time of writing I have not performed such migration, so carefully figure out how to do it yourself using the upgrade instructions of Overleaf Toolkit. Note that you can create backups, see https://github.com/overleaf/overleaf/wiki/Data-and-Backups. You should check whether upgrading is possible, and if there are instructions associated with doing so. If the CEP Community project does not provide such instructions, you should check out the Overleaf Community Edition release notes and the Overleaf Toolkit upgrade instructions.

Offer a historic version of TeXLive

At the time of writing, TeXLive 2024 was released (docker hub: texlive/texlive:TL2024-historic). These are the steps that I executed.

  1. Open config/variables.env to update the available TeXLive images.

    ALL_TEX_LIVE_DOCKER_IMAGES=texlive/texlive:latest-full,texlive/texlive:TL2024-historic,texlive/texlive:TL2023-historic
    ALL_TEX_LIVE_DOCKER_IMAGE_NAMES=TeXLive 2025,TeXLive 2024,TeXLive 2023
  2. (optional) pull the new historic docker image docker pull texlive/texlive:TL2024-historic

  3. Run bin/mongo

  4. Update projects to refer to the image of TeXLive that they were using (in my case, 2024) instead of automatically rolling them to 2025. You can see how many documents were using the latest as follows:

    db.projects.find({imageName: "texlive/texlive:latest-full"}).count()

    Remove the argument to find to count all documents. You can update the projects as follows:

    db.projects.updateMany({"imageName": "texlive/texlive:latest-full"}, {$set: { "imageName": "texlive/texlive:TL2024-historic"}})
  5. Restart overleaf to make the updated variables.env take effect.

RSS
https://sxv.be/blog/feed.xml