Personal Privacy

Login Advanced Search
     General TopicsSelf Hosted ServicesServer Setup

Setting up Self-Hosted Latex Server

Installation

First

sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt-cache policy docker-ce
sudo apt install docker-ce
sudo systemctl status docker
sudo usermod -aG docker ${USER}
su - ${USER}
cd ~
git clone https://github.com/overleaf/toolkit.git ./overleaf
cd overleaf
bin/init --tls
nano ~/overleaf/config/overleaf.rc

and make these changes

...
SHARELATEX_PORT=4221
...
NGINX_ENABLED=false
...
NGINX_HTTP_PORT=4221
...
TLS_PRIVATE_KEY_PATH=/etc/letsencrypt/live/WEBSITE.com/privkey.pem
TLS_CERTIFICATE_PATH=/etc/letsencrypt/live/WEBSITE.com/fullchain.pem
...

Save and close. Then

nano ~/overleaf/config/variables.env

make these changes

SHARELATEX_APP_NAME='APP NAME'
...
SHARELATEX_BEHIND_PROXY=true
SHARELATEX_SECURE_COOKIE=true
SHARELATEX_SITE_URL=https://WEBSITE.com
SHARELATEX_NAV_TITLE='Website Name'
...
SHARELATEX_ADMIN_EMAIL='admin@website.com'

Open

nano ~/overleaf/lib/docker-compose.base.yml

and add this under sharelatex section:

services:
  ...
  sharelatex:
    ...
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=1

Next, create the Nginx config

sudo nano /etc/nginx/sites-available/latex.conf

and paste

server {
    server_name WEBSITE.com;

    add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";

    server_tokens off;

    client_max_body_size 50M;

    location / {
      proxy_pass http://localhost:4221; # The port must match the value of SHARELATEX_PORT.
      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;
    }
}

Save and close.

sudo systemctl nginx restart
sudo certbot --nginx -d WEBSITE.com
sudo systemctl nginx restart
cd ~/overleaf
bin/up

After the initialization succeeded and it started showing the connections, press Ctrl+C. Next, we can install the full version of LaTex.
This will take several minutes as it needs to download 5-10 GB.

bin/start
docker exec sharelatex tlmgr update --self
docker exec sharelatex tlmgr install scheme-full

Next, find out the latest version you downloaded using

nano ~/overleaf/config/version

Based on the version you found, enter

docker commit sharelatex sharelatex/sharelatex:4.1.6

Next

cd ~/overleaf
bin/up
bin/start

Then, go to https://WEBSITE.com/launchpad to create the admin account.

Buy me a coffe?!


Comments

No comments yet!
Add a new comment:

7