Skip to content

About

Share your Immich photos and albums in a safe way without exposing your Immich instance to the public.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

Immich Public Proxy (fork)

This is a fork of Immich Public Proxy by Alan Grainger. All of the original design and nearly all of the code are his. If you want the supported version, use his. Upstream docs: https://docs.ipp.nz

This fork is 100% AI-coded. Every change here was written by an AI assistant (Claude) at my direction, then built and tested before it was committed. Review it before trusting it with anything that matters. Problems with this fork belong here, not upstream.

What it does

Immich Public Proxy (IPP) sits between the internet and your Immich server and serves only what you have shared with a public link in Immich. Immich itself stays private. IPP needs no API key and stores nothing. Sharing is still managed in Immich: create a shared link there, and IPP serves it as a gallery at https://your-ipp-host/share/<key>.

An optional second container, the upload service, lets visitors add photos to a share that allows public uploads (for example, guests at a wedding).

What is different in this fork

  • Configuration is environment variables only. There is no config.json. Every option has a variable, such as IPP_GALLERY_SINGLE_IMAGE=true. Invalid values log a warning and fall back to the default. Unknown IPP_* variables are reported with a "did you mean" suggestion. A leftover CONFIG or IPP_CONFIG variable stops the container at startup, so an old config is never silently ignored.
  • Logging rewritten. Levels are LOG_LEVEL=error|warn|info|debug|trace. Timestamps use local time (set TZ), with milliseconds and the UTC offset. Each line has a component tag ([immich], [share], [zip], [upload], [http]). Share keys are always shortened in logs. debug adds a per-request access log.
  • Security hardening:
    • Real visitor IPs behind a reverse proxy (IPP_TRUST_PROXY).
    • A wrong-password lockout per visitor and share.
    • A strict Content-Security-Policy, with no inline scripts.
    • nosniff, Referrer-Policy: same-origin and framing protection.
    • Dependencies patched.
  • Graceful shutdown. In-flight downloads and uploads get a few seconds to finish when the container stops.
  • Images: linux/amd64 only, published to GHCR. No Docker Hub, no arm64.
  • Lean repo: upstream's VitePress docs site, Docker Hub/multi-arch pipeline, issue templates and contributor guide are gone. Configuration is documented in CONFIGURATION.md.

Images

Image Purpose
ghcr.io/upmcplanetracker/immich-public-proxy:latest The proxy (gallery, downloads, password pages)
ghcr.io/upmcplanetracker/immich-public-proxy-upload:latest Optional visitor upload service

Built by .github/workflows/ci.yaml: one build per image, linux/amd64, pushed to GHCR with the repository's GITHUB_TOKEN. Pushing commits never builds anything. Only these do:

  • Pushing a v* tag (a release) publishes X.Y.Z, X.Y, latest and sha-<short>.
  • Running it by hand (Actions tab → Build and publish Docker images → Run workflow) builds the chosen branch as edge and sha-<short>, for testing. latest and the version tags are left alone.

Versions. This fork has its own version line, starting at 1.0.0. It was forked from upstream 4.2.0, and the two are unrelated. The running app reports the release (1.0.3), or <version>-<sha> for a manual build, in its startup log. Static files are cache-busted with that version, so every build gets fresh CSS and JS.

To release:

npm run bump -- 1.0.4        # sets all three package.json files + lockfile
git commit -am "Release 1.0.4" && git push
git tag v1.0.4 && git push origin v1.0.4

Dependabot (.github/dependabot.yml) opens weekly PRs on Mondays for npm, the Docker base image and GitHub Actions. Minor and patch updates are grouped, one PR per ecosystem; majors get their own PR. CI doesn't run on PRs, so run npm ci && npm test locally (or check out the PR branch) before merging. Merging doesn't build; the update ships with your next release tag.

Quick start

  1. Copy .env.example to ipp.env. Every variable in it is already set to its default. Change IMMICH_URL to Immich's address as seen from the container (not your public URL), and set TZ.
  2. Run the container with that file (Quadlet, compose or podman run; examples below).
  3. Put it behind your reverse proxy and check that https://your-ipp-host/share/healthcheck returns ok.
  4. In Immich, go to Administration → Settings → Server Settings and set External domain to your IPP URL. Share links Immich creates from then on point at IPP.

Podman Quadlet (rootless)

~/.config/containers/systemd/immich-public-proxy.container:

[Unit]
Description=Immich Public Proxy

[Container]
Image=ghcr.io/upmcplanetracker/immich-public-proxy:latest
ContainerName=immich-public-proxy
EnvironmentFile=%h/immich-public-proxy/ipp.env
PublishPort=3000:3000
ReadOnly=true
DropCapability=ALL
NoNewPrivileges=true
HealthCmd=curl -sf -m 4 http://localhost:3000/share/healthcheck -o /dev/null || exit 1
HealthStartPeriod=10s
AutoUpdate=registry
# Give IPP_SHUTDOWN_TIMEOUT (default 8 s) room to finish open transfers
StopTimeout=15

[Service]
Restart=always

[Install]
WantedBy=default.target

Then run systemctl --user daemon-reload && systemctl --user start immich-public-proxy.

Put settings in the EnvironmentFile= rather than in Environment= lines. Podman reads an env file literally, but systemd splits Environment= values at spaces and strips quotes. That breaks any value with spaces or JSON in it (IPP_CONTENT_SECURITY_POLICY, IPP_TRUST_PROXY, IPP_RESPONSE_HEADERS, IPP_LIGHTBOX_OPTIONS, IPP_UPLOAD_NOTIFY_HEADERS). IPP spots this and falls back to the default with a warning. Simple values such as Environment=IPP_ALLOW_DOWNLOAD=1 are fine either way. Only set what you change: an unset variable already uses its default.

Docker / Podman Compose

See docker-compose.yml. Either uncomment its env_file: line and point it at your env file, or list the variables under environment:.

Upload service (optional)

Run immich-public-proxy-upload the same way, with its own port (for example, 3001:3000) and the same IMMICH_URL and PUBLIC_BASE_URL. Its healthcheck is http://localhost:3000/healthcheck. Your reverse proxy should route /upload/* on the IPP hostname to it. IPP's IPP_UPLOAD_URL defaults to /upload, and the gallery only shows the "Add photos" button when that path answers.

The container also includes a CLI that tags visitor uploads in Immich by the name in their filename. It needs an Immich API key:

podman exec -e IMMICH_API_KEY=<key> ipp-upload node dist/tag-uploads.js          # dry run
podman exec -e IMMICH_API_KEY=<key> ipp-upload node dist/tag-uploads.js --apply

How sharing works

Multiple Immich users

IPP isn't tied to a user. The share key in the URL is the only credential: for /share/<key>, IPP asks Immich about that key exactly as an anonymous browser would, and Immich answers with the link's owner and photos. IPP has no login, no API key and no list of users, so every user on the server can share through it.

  • Per-link options are each user's own: password, expiry, "Allow download" (when IPP_ALLOW_DOWNLOAD=1), "Show metadata" (off hides metadata even where IPP_SHOW_METADATA_* would show it) and "Allow public user to upload".
  • IPP_* settings apply to every user's shares. They set the ceiling: which metadata fields can show, download quality, gallery layout.
  • Visitor uploads go to the user who owns the shared link, in that share's album.
  • Nothing outside a shared link is reachable. The most a visitor can see is what that one key covers.

Two domains: Immich and the share domain

Immich's Administration → Settings → Server Settings → External Domain only changes the URL Immich puts in the share links it hands out. It doesn't move Immich. With Immich at immich.example.com and IPP at photos.example.com:

  1. Set External Domain to https://photos.example.com. Every user's Share button now produces https://photos.example.com/share/<key>, or /s/<slug> for custom URLs, and IPP serves both. Immich stores the key, not the domain, so links created earlier move to the new domain too.
  2. Route photos.example.com only to IPP (port 3000). Nothing under it should reach Immich.
  3. Set PUBLIC_BASE_URL=https://photos.example.com so link previews in messaging apps use the right address.
  4. If you run the upload service, route photos.example.com/upload/* to it.
  5. Keep immich.example.com on your LAN or VPN if you can. Immich still answers /share/<key> on its own domain, so if it is public, IPP is a second way in rather than the only one.

Check: open a new share link in a private window. The address should be photos.*, and with LOG_LEVEL=debug IPP logs Serving share abc123… (N items) and an [http] line with your public IP.

Configuration

Everything is an environment variable. The full reference, with defaults, accepted values and which container reads each one, is in CONFIGURATION.md. Both files are generated from shared/src/config/schema.ts, so they can't drift from the code.

The variables you are most likely to set:

Variable Default What it does
IMMICH_URL (required) Immich as reached from inside the container
PUBLIC_BASE_URL from request Public URL of IPP, used for link-preview images
TZ UTC Time zone for log timestamps
LOG_LEVEL info error, warn, info, debug or trace
IPP_ALLOW_DOWNLOAD 0 0 = no download buttons, 1 = follow each share's Immich setting, 2 = always
IPP_GALLERY_GROUP_BY_DATE false false, month or day
IPP_SHOW_METADATA_* all false Per-field EXIF and location info shown to visitors
IPP_TRUST_PROXY private ranges Which proxies may supply the visitor IP
IPP_PASSWORD_MAX_ATTEMPTS 10 Wrong passwords per visitor per share before lockout
IPP_CONTENT_SECURITY_POLICY strict false disables it; any other value replaces it
IPP_UPLOAD_MAX_FILE_SIZE 500 Largest visitor upload, in MB

To migrate from upstream's config.json, write each JSON path in upper snake case: ipp.gallery.singleImage becomes IPP_GALLERY_SINGLE_IMAGE, and ipp.upload.maxFileSize becomes IPP_UPLOAD_MAX_FILE_SIZE.

Reverse proxy notes

  • VPS over WireGuard: use the VPS proxy's reverse_proxy (Caddy) or proxy_pass (nginx) to IPP's tunnel address. Don't DNAT the port straight through, or every visitor shows up as the VPS. With LOG_LEVEL=debug, the [http] lines should show public visitor IPs.
  • Cloudflare: request bodies are capped at 100 MB, so set IPP_UPLOAD_CHUNK_SIZE=90 for uploads. Bypass the cache for /share/video/*.
  • HSTS belongs on the proxy in front, since IPP only ever sees plain HTTP.

Details are in CONFIGURATION.md.

Packages

The repository is an npm workspace with three packages:

Package Path What it is
@ipp/core shared/ Shared code: Immich client, config schema and loader, logging, sessions, security headers, page rendering
immich-public-proxy app/ The proxy: share pages, gallery, lightbox, assets, zip downloads
immich-public-proxy-upload upload-app/ The upload service and the tag-uploads CLI

Runtime dependencies (nothing else ships in the images):

Dependency Used for
express 5 HTTP server and routing
cookie-session Signed session cookie holding encrypted share passwords (1 hour)
preact 11, preact-render-to-string Server-rendered HTML pages
archiver 8 Streaming "download all" zip files
dayjs Dates and log timestamps
dotenv Optional .env file in the working directory
tslib TypeScript helpers

Vendored in the browser: PhotoSwipe (lightbox), thumbhash (blurred placeholders) and Pico CSS (password page).

Build and test tools: TypeScript 6, Vitest 5, ESLint 10 (neostandard + typescript-eslint, eslint.config.mjs), tsx and concurrently.

Development

Requires Node 22.12 or newer (archiver 8 is ESM-only and is loaded with require(esm)) and npm 11. The lockfile is generated with npm 11, because npm 10 crashes on this workspace.

npm ci
npm run build          # shared, app, upload-app
npm test               # unit tests for all three packages
npm run lint
npm run docs:config    # regenerate CONFIGURATION.md and .env.example after changing the schema
npm run dev            # watch mode for everything

To add an option, add one entry to shared/src/config/schema.ts, read it with getConfigOption('ipp.x.y'), and run npm run docs:config. A test fails if the docs are stale.

Conventions: log through log.child('<component>') at the right level (never raw console.* in server code), mask share keys with maskKey/maskPath, and keep pages free of inline scripts (the CSP blocks them).

License

AGPL-3.0, the same as upstream. See LICENSE.

Credit again to Alan Grainger for Immich Public Proxy, and to Dmytro Semenov for PhotoSwipe.

About

Share your Immich photos and albums in a safe way without exposing your Immich instance to the public.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages