overleaf / overleaf/toolkit

Overleaf + nginx on a seperate path from root

Open
#309 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
1.3k
Forks
310
Avg merge
3d 12h
Merged PRs (30d)
1

Description

Steps to Reproduce

Config of overleaf.rc (pretty standard stuff):

#### Overleaf RC ####

PROJECT_NAME=overleaf

# Sharelatex container
# Uncomment the OVERLEAF_IMAGE_NAME variable to use a user-defined image.
# OVERLEAF_IMAGE_NAME=sharelatex/sharelatex
OVERLEAF_DATA_PATH=/overleaf_data/overleaf
SERVER_PRO=false
OVERLEAF_LISTEN_IP=127.0.0.1
OVERLEAF_PORT=8314

# Sibling Containers
SIBLING_CONTAINERS_ENABLED=true
DOCKER_SOCKET_PATH=/var/run/docker.sock

# Mongo configuration
MONGO_ENABLED=true
MONGO_DATA_PATH=/overleaf_data/mongo
MONGO_IMAGE=mongo
MONGO_VERSION=6.0

# Redis configuration
REDIS_ENABLED=true
REDIS_DATA_PATH=/overleaf_data/redis
REDIS_IMAGE=redis:6.2
REDIS_AOF_PERSISTENCE=true

# Git-bridge configuration (Server Pro only)
GIT_BRIDGE_ENABLED=false
GIT_BRIDGE_DATA_PATH=data/git-bridge

# TLS proxy configuration (optional)
# See documentation in doc/tls-proxy.md
NGINX_ENABLED=false
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=127.0.1.1
NGINX_TLS_LISTEN_IP=127.0.1.1
TLS_PRIVATE_KEY_PATH=config/nginx/certs/overleaf_key.pem
TLS_CERTIFICATE_PATH=config/nginx/certs/overleaf_certificate.pem
TLS_PORT=443

Config of variables.env:

OVERLEAF_APP_NAME="My Overleaf"

ENABLED_LINKED_FILE_TYPES=project_file,project_output_file

# Enables Thumbnail generation using ImageMagick
ENABLE_CONVERSIONS=true

# Disables email confirmation requirement
EMAIL_CONFIRMATION_DISABLED=true

## Nginx
# NGINX_WORKER_PROCESSES=4
# NGINX_WORKER_CONNECTIONS=768

## Set for TLS via nginx-proxy
OVERLEAF_BEHIND_PROXY=true
# OVERLEAF_SECURE_COOKIE=true

OVERLEAF_SITE_URL=http://[my_website].[a_tld]/overleaf/
OVERLEAF_NAV_TITLE="My Overleaf"
OVERLEAF_HEADER_IMAGE_URL=a_link_to_an_image.com/1
OVERLEAF_ADMIN_EMAIL="my@email.com"

OVERLEAF_LEFT_FOOTER='[{"text": "Contact Server Admins", "url": "mailto:my@email.com"}]'
# OVERLEAF_RIGHT_FOOTER='[{"text": "Hello, I am on the Right"}]'

# OVERLEAF_EMAIL_FROM_ADDRESS=team@example.com

# OVERLEAF_EMAIL_AWS_SES_ACCESS_KEY_ID=
# OVERLEAF_EMAIL_AWS_SES_SECRET_KEY=

# OVERLEAF_EMAIL_SMTP_HOST=smtp.example.com
# OVERLEAF_EMAIL_SMTP_PORT=587
# OVERLEAF_EMAIL_SMTP_SECURE=false
# OVERLEAF_EMAIL_SMTP_USER=
# OVERLEAF_EMAIL_SMTP_PASS=
# 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=This system is run by department x

... Overleaf Pro config ...

Config of nginx.conf:

server {
    listen 80;
    server_name _;

    # Location block to proxy Overleaf
    location /overleaf/ {
        # Use the ShareLaTeX container name in proxy_pass
        proxy_pass http://sharelatex:80/;

        # Set headers to pass client information to Overleaf
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto http;

        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Timeout settings
        proxy_read_timeout 3m;
        proxy_send_timeout 3m;
    }

    server_tokens off;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;

    client_max_body_size 50M;
}
  1. Start nginx docker alpine container with the config above with:
    docker run -d --name nginx-overleaf --network overleaf_default -p 80:80 -v path/to/nginx.conf:/etc/nginx/conf.d/default.conf nginx:alpine
  2. Start the Overleaf instance with bin/up -d
  3. Go to http://[my_website].[a_tld]/overleaf/

Expected Behaviour

If I go to http://[my_website].[a_tld]/overleaf/, I will get redirected to http://[my_website].[a_tld]/overleaf/login

Observed Behaviour

If I go to http://[my_website].[a_tld]/overleaf/, I get redirected to http://[my_website].[a_tld]/login. Of course, nothing is to be found there. However, If I actually type http://[my_website].[a_tld]/overleaf/login into my browser, I get to the login page.

However, If we change the value of OVERLEAF_SITE_URL to OVERLEAF_SITE_URL=http://[my_website].[a_tld]/ (and adjust the nginx config), i.e., host it on the root path, everything works as intended.

Context

We want to host multiple services on our server on subpaths. This is currently not possible.

Technical Info

We are running this on a VM with Debian Bookworm. Subdomains are currently not available in our setup.

Analysis

It looks like OVERLEAF_SITE_URL does not get passed correctly to the container?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied overleaf.rc, variables.env, and nginx.conf configurations, then reproduce the redirect using the listed Docker and bin/up commands. Trace how OVERLEAF_SITE_URL and the /overleaf/ proxy path are handled, comparing the subpath setup with the working root-path setup. Done means visiting /overleaf/ redirects to /overleaf/login and the service works under a subpath.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, nginx
Domain
infrastructure, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.