VPS with HTTPS
No server at home? A small rented server (VPS) works too. The site is then on the internet from the start, so this guide puts Caddy in front of it for automatic HTTPS, and everyone logs in.
What you need
Section titled “What you need”- A VPS with 2 GB of memory (1 vCPU is enough), Ubuntu 24.04 or Debian 13, and SSH access.
- A domain name (or subdomain) for the site, for example
models.example.com. - A way to get your models onto the server (step 4).
-
Point your domain at the server. At your DNS provider, create an
Arecord formodels.example.comwith the VPS’s IP address (and anAAAArecord for its IPv6 address, if it has one). If your DNS is at Cloudflare, set it to DNS only, so Caddy can get its certificate. -
Open only SSH, HTTP and HTTPS in the firewall:
Terminal window sudo ufw allow OpenSSHsudo ufw allow 80,443/tcpsudo ufw enablePort 8085 stays closed: the site is only reachable through Caddy (step 5 binds it to the server itself).
-
Put your models on the server, for example in
/srv/3d-prints. Pick what fits where they are now: -
Get the site’s files and settings:
Terminal window sudo mkdir -p /opt/3mf-library && sudo chown $USER /opt/3mf-library && cd /opt/3mf-librarycurl -fsSLO https://raw.githubusercontent.com/jurjen74/3mf-library/main/docker-compose.ymlcurl -fsSL -o .env https://raw.githubusercontent.com/jurjen74/3mf-library/main/.env.examplemkdir -p data && sudo chown 1000:1000 dataIn
.env:Terminal window LIBRARY_DIR=/srv/3d-printsPORT=127.0.0.1:8085 # only reachable on the server itselfTRUSTED_NETWORKS= # no home network here: everyone logs inKNOWN_PROXIES=172.30.0.2 # Caddy, see the next stepTZ=Europe/Amsterdam -
Add Caddy. Create
docker-compose.override.ymlnext to the other file (Docker Compose reads it automatically):services:3mf-library:networks: [web]caddy:image: caddy:2restart: unless-stoppedports:- "80:80"- "443:443"- "443:443/udp"volumes:- ./Caddyfile:/etc/caddy/Caddyfile:ro- caddy-data:/data- caddy-config:/confignetworks:web:ipv4_address: 172.30.0.2networks:web:ipam:config:- subnet: 172.30.0.0/24volumes:caddy-data:caddy-config:And a file
Caddyfilewith your domain:models.example.com {reverse_proxy 3mf-library:8080} -
Start everything:
Terminal window docker compose up -ddocker compose logs -f caddy # wait for "certificate obtained successfully" -
Create the first account. That can’t be done through a proxy, so open the site directly through an SSH tunnel. On your own computer:
Terminal window ssh -L 8085:127.0.0.1:8085 user@vpsOpen
http://localhost:8085, and enter the setup code from the log (in the SSH session):Terminal window docker logs 3mf-library | grep "setup code"Close the tunnel afterwards. From now on, use
https://models.example.comand log in.
Updating
Section titled “Updating”cd /opt/3mf-library && docker compose pull && docker compose up -d && docker image prune -fThis updates Caddy as well.
Good to know
Section titled “Good to know”- Everyone logs in. Without
TRUSTED_NETWORKSthere’s no “home network”; failed logins are rate-limited per visitor (Caddy passes the real address, becauseKNOWN_PROXIESpoints at it). - Backups:
data/users.dbholds the accounts; see Updating and backups. - Already running a reverse proxy on the server? Skip Caddy, publish the site to that proxy and set
KNOWN_PROXIESto its address (Reverse proxy and HTTPS).