Skip to content

Instantly share code, notes, and snippets.

@antiops
Created December 6, 2021 14:29
Show Gist options
  • Select an option

  • Save antiops/dee3aca993799839faa6f33a98b74ab5 to your computer and use it in GitHub Desktop.

Select an option

Save antiops/dee3aca993799839faa6f33a98b74ab5 to your computer and use it in GitHub Desktop.
paperless-ng with cloudflare argo tunnel together

Implement cloudflared directly in the paperless-ng docker-compose.yml file.

This requires you to have the cloudflared tunnel config.json & <uuid>.json already generated as well as the dns cname.

  • If you do not go follow the steps on Cloudflares docs Here and stop at step 6.

 

  1. Copy the .json files that were generated in ~/.cloudflared to your paperless-ng folder in a new folder called cloudflared

  2. Edit the config.json file and modify the credentials-file value to point to /etc/cloudflared/<uuid>.json & remove the line with url

  3. Copy the section of the docker-compose.yml file on this page that has cloudflare to the docker-compose in your paperless-ng folder.

    • Copy cloudflare: down to TUNNEL_URL: http://webserver:8000.
    • Formatting and indents matter! Make sure it matches the formatting of yours.
  4. After all that run docker-compose up -d in your paperless-ng folder to update your paperless stack to include cloudflared and automatically create and proxy your instance through the dns zone you set up earlier.

If the cloudflared container errors and keeps restarting you can check the docker logs of it and the error will say what the problem is


Sidenotes:

  • You may want to check what the latest version of cloudflared available on Docker Hub since cloudflare doesnt provide a :latest. If its newer than 2021.11.0 then modify the docker-compose to reflect the new version and run docker-compose up -d to rebuild you stack with the latest version.
  • The entire docker-compose.yml file on this page is the tika version and is only modified to bind the data and media folders directly to the paperless-ng folder instead of using docker volumes to make easy client-side backups. You can use the entire thing if youre doing a fresh install.

References: https://github.com/judge2020/docker-cloudflared

version: "3.4"
services:
broker:
image: redis:6.0
restart: unless-stopped
webserver:
image: jonaswinkler/paperless-ng:latest
restart: unless-stopped
depends_on:
- broker
- gotenberg
- tika
ports:
- 127.0.0.1:8000:8000
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000"]
interval: 30s
timeout: 10s
retries: 5
volumes:
- ./data:/usr/src/paperless/data
- ./media:/usr/src/paperless/media
- ./export:/usr/src/paperless/export
- ./consume:/usr/src/paperless/consume
env_file: docker-compose.env
environment:
PAPERLESS_REDIS: redis://broker:6379
PAPERLESS_TIKA_ENABLED: 1
PAPERLESS_TIKA_GOTENBERG_ENDPOINT: http://gotenberg:3000
PAPERLESS_TIKA_ENDPOINT: http://tika:9998
gotenberg:
image: thecodingmachine/gotenberg
restart: unless-stopped
environment:
DISABLE_GOOGLE_CHROME: 1
tika:
image: apache/tika
restart: unless-stopped
cloudflare:
image: cloudflare/cloudflared:2021.11.0
command: tunnel run
restart: unless-stopped
depends_on:
- webserver
volumes:
- ./cloudflared:/etc/cloudflared
environment:
TUNNEL_URL: http://webserver:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment