Overleaf + nginx on a seperate path from root
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="[email protected]"
OVERLEAF_LEFT_FOOTER='[{"text": "Contact Server Admins", "url": "mailto:[email protected]"}]'
# OVERLEAF_RIGHT_FOOTER='[{"text": "Hello, I am on the Right"}]'
# [email protected]
# 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;
}
- 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 - Start the Overleaf instance with
bin/up -d - 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?
Seems like https://github.com/overleaf/toolkit/issues/87 is addressing the same goal. @konwin seems to have found a solution using traefik. I couldn't reproduce the solution myself.
Has anyone managed to launch overleaf as a service over https://<IP>/overleaf?