Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ RAILS_MIN_THREADS=4
RAILS_MAX_THREADS=16
PGDATA="/var/lib/postgresql/data"
OPDATA="/var/openproject/assets"
OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL=ws://localhost:8080/hocuspocus
OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET=secret12345
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ x-op-app: &app
RAILS_CACHE_STORE: "memcache"
OPENPROJECT_CACHE__MEMCACHE__SERVER: "cache:11211"
OPENPROJECT_RAILS__RELATIVE__URL__ROOT: "${OPENPROJECT_RAILS__RELATIVE__URL__ROOT:-}"
OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL: "${OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__URL}"
OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET: "${OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET}"
DATABASE_URL: "${DATABASE_URL:-postgres://postgres:p4ssw0rd@db/openproject?pool=20&encoding=unicode&reconnect=true}"
RAILS_MIN_THREADS: ${RAILS_MIN_THREADS:-4}
RAILS_MAX_THREADS: ${RAILS_MAX_THREADS:-16}
Expand Down Expand Up @@ -51,6 +53,7 @@ services:
context: ./proxy
args:
APP_HOST: web
HOCUSPOCUS_HOST: hocuspocus
image: openproject/proxy
<<: *restart_policy
ports:
Expand Down Expand Up @@ -114,3 +117,10 @@ services:
restart: on-failure
networks:
- backend

hocuspocus:
image: openproject/hocuspocus:main-88913ad0
networks:
- frontend
environment:
SECRET: "${OPENPROJECT_COLLABORATIVE__EDITING__HOCUSPOCUS__SECRET}"
20 changes: 13 additions & 7 deletions proxy/Caddyfile.template
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
:80 {
reverse_proxy * http://${APP_HOST}:8080 {
# The following directives are needed to make the proxy forward explicitly the X-Forwarded-* headers. If unset,
# Caddy will reset them. See: https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults
# This is needed, if you are using a reverse proxy in front of the compose stack and Caddy is NOT your first
# point of contact.
# When using Caddy is reachable as a first point of contact, it is highly recommended to configure the server's
# global `trusted_proxies` directive. See: https://caddyserver.com/docs/caddyfile/options#trusted-proxies
# Reverse proxy for WebSocket connections
@hocuspocus {
path /hocuspocus*
}
reverse_proxy @hocuspocus ${HOCUSPOCUS_HOST}:1234 {
header_up X-Forwarded-Proto {header.X-Forwarded-Proto}
header_up X-Forwarded-For {header.X-Forwarded-For}
}

# Reverse proxy for all other HTTP requests
@app {
not path /hocuspocus*
}
reverse_proxy @app ${APP_HOST}:8080 {
header_up X-Forwarded-Proto {header.X-Forwarded-Proto}
header_up X-Forwarded-For {header.X-Forwarded-For}
}
Expand Down
5 changes: 4 additions & 1 deletion proxy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM caddy:2
COPY ./Caddyfile.template /etc/caddy/Caddyfile.template

ARG APP_HOST
RUN sed 's|${APP_HOST}|'"$APP_HOST"'|g' /etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile
ARG HOCUSPOCUS_HOST
RUN sed -e 's|${APP_HOST}|'"$APP_HOST"'|g' \
-e 's|${HOCUSPOCUS_HOST}|'"$HOCUSPOCUS_HOST"'|g' \
/etc/caddy/Caddyfile.template > /etc/caddy/Caddyfile

ENTRYPOINT ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]