FotobogenDocumentation

Configuration

Every value Fotobogen runs on is written down in one file, fotobogen.config.js. This page lists all of them: what each does, what you can change, and what you should leave alone.

How a setting is decided

For each setting, Fotobogen uses the first of these that has a value:

  1. An environment variable set when the app is started.
  2. The .env file in Fotobogen's folder.
  3. fotobogen.config.js, which holds the defaults.

So the file is the list of defaults, and .env is where you change them for one server.

Changing a setting: use .env

cp .env.sample .env     # once; then edit .env

Write one setting to a line, such as PORT=8080, and restart Fotobogen. A restart is all a change to .env ever needs; nothing is rebuilt. Three reasons to do it this way and not edit the config file:

Running withTo restart after editing .env
pnpm startStop it with Control + C, and run pnpm start again
pm2pm2 restart fotobogen
Dockerdocker compose up -d, which starts the container again with the new values

Two things to know. Under pm2, ecosystem.config.cjs takes the port from PORT in .env (5150 if it is not set); after changing it, run pm2 reload ecosystem.config.cjs --update-env, because pm2 remembers the port it was started with. That file also sets the address to listen on, the data folder, and TRUST_PROXY, which win over .env. Under Docker, the same .env file is read, and the compose files pass these settings through to the app: the upload limits, SITE_URL, ADMIN_HOST, DEMO_MODE, WEBHOOKS_ALLOW_PRIVATE, TWO_STEP_KEY, and TWO_STEP_KEY_FILE.

The two parts of the file

PartWhat is in itChange it?
Okay to changeThe port, the address, where data is kept, upload limits, webhooksYes. Each has a name to use in .env, except portAttempts.
Do not touch (internals)Image sizes, memory limits, queue and login rules, what a machine must haveNo. They have no .env names on purpose. The app is built and tested around these values.

Settings about the site (its title, its look, its words, what search engines are told) are not in this file at all. They are set in the admin and stored in the site's database. See Customization.

Okay to change: the server

server.port

Default5150
In .envPORT=5150

The port Fotobogen listens on. 5150 keeps clear of the ports other tools take first (3000, 8000, 8080).

With Docker, this is the port on the host that is passed to the app (the Forge compose file), and the app inside the container always uses 5150.

server.portAttempts

Default10
In .envNone. Change it in the file, then pnpm build.

How many ports above the default to try before giving up. With the default, Fotobogen tries 5150 to 5159. There is rarely a reason to change it.

server.host

Default'0.0.0.0' (every network interface)
In .envHOST=127.0.0.1

The network address to listen on. 0.0.0.0 accepts connections from other machines. Use 127.0.0.1 when a proxy on the same machine (nginx, Caddy) is the only thing that should reach the app, so that nobody can go around the proxy.

server.trustProxy

Defaultfalse
In .envTRUST_PROXY=1

Tells Fotobogen that every request reaches it through your own reverse proxy, so the visitor's real address is in the X-Forwarded-For header and the scheme (http or https) in X-Forwarded-Proto. The login limit then counts failures by visitor, not by proxy.

Turn it on only when the app cannot be reached directly. If it is on and the app is exposed, anyone can send those headers themselves and dodge the login limit. The Docker and pm2 files that come with Fotobogen turn it on, because they put the app behind a proxy.

server.siteUrl

Default'' (none)
In .envSITE_URL=https://photos.example.com
In the adminSearch and sharing, "Your site's proper address"

The site's proper address. It is used wherever a full address is written out: the links on a photo's admin page, canonical links, the RSS feed, the sitemap, and robots.txt.

server.demoMode

Defaultfalse
In .envDEMO_MODE=1

For a site meant to show Fotobogen off. When it is on, the login page says the site is a demonstration, and anyone can log in with the username demo and the password demo.

Okay to change: where data is kept

dataDir

Default'./data'
In .envDATA_DIR=/srv/photos

The folder that holds everything the site owns: the database, your photographs as uploaded, the resized copies, and installed skins and modules. A path that does not start with / is taken from the folder Fotobogen is started in.

Okay to change: uploads

uploads.maxUploadMb

Default50
In .envMAX_UPLOAD_MB=120

The largest file accepted, in megabytes. A larger upload is refused with a message saying so.

If you raise it, raise the limit of the web server in front of Fotobogen too, or that will refuse the upload first with a less helpful message: max_size in deploy/Caddyfile, or client_max_body_size in nginx.

uploads.maxMegapixels

Default100
In .envMAX_MEGAPIXELS=60

The largest image accepted, in megapixels: its width times its height, divided by a million. A 9504 by 6336 photograph is 60 megapixels. This limit exists because a small file can unpack into an enormous image that fills the server's memory.

Lower it on a server with little memory. Raising it above 100 is safe only with memory to match. Four formats have their own lower limits, which this setting does not raise; see formatMegapixels.

Okay to change: webhooks

webhooks.allowPrivate

Defaultfalse
In .envWEBHOOKS_ALLOW_PRIVATE=1

A webhook sends a message to an address you enter in the admin. By default it may only call addresses on the public internet, so that a webhook cannot be pointed at this machine or at the private network behind it. The check is made again at the moment of connecting, so a name that changes what it points to does not get through.

Turn this on only if you want to call something on your own network, such as an automation tool on the same server.

Okay to change: two-step login

Two-step login is switched on in the admin, under Two-step login, not here. These two settings are in .env only, and only say where its key comes from. Most installs need neither.

TWO_STEP_KEY_FILE

Default.fotobogen/two-step-key.json in your home folder; in Docker, two-step-key.json in the data folder
In .envTWO_STEP_KEY_FILE=/path/to/two-step-key.json

The file the key is kept in. Every Fotobogen that reads the same file shares one key, and so one entry in your authenticator app. Name a different file to give a site a key of its own. The file is made the first time two-step login is set up, readable by your account alone.

TWO_STEP_KEY

Defaultnot set
In .envTWO_STEP_KEY=ABCD EFGH IJKL MNOP QRST UVWX YZ23 4567

The key itself, as an authenticator app shows it: letters A to Z and digits 2 to 7, at least 26 of them. When it is set, no file is used. It is for giving several Docker sites one entry in the app: set it in each site's .env. Changing it does not change a site that already has two-step login on: each site keeps its own copy from the moment it was switched on.

Do not touch: internals

These are listed so you can read them, not so you can tune them. The rest of the app is built and tested around these values. Changing one can break a site that already has photos, waste disk space, or run a small server out of memory. None has a name in .env. If one of them is wrong for you, that is worth raising as an issue, so it can be made a proper setting.

internals.derivatives: the resized copies

The sizes of the copies made of every photo, in pixels. Nothing is ever enlarged: a photo smaller than a size gets a copy at its own size.

SettingValueWhat it is
derivatives.thumbWidth480The thumbnail in the grid: this wide, whatever height keeps the photo's shape.
derivatives.squareSize480The square crop used by the square grid, cut around the most interesting part of the photo.
derivatives.mediumEdge1280The long side of the medium copy, shown on small screens and used as the sharing picture.
derivatives.largeEdge2560The long side of the large copy, shown on large screens and handed out as a download. Also the size every photo is reduced to before anything else is done, which is what keeps memory use small.
derivatives.webpQualitythumb: 78, square: 78, medium: 82, large: 82How hard each copy is compressed as WebP, from 1 to 100. Higher is larger and closer to the original. These are the values of the Standard choice; to use others, choose Smaller files or High in the admin under Settings, Picture quality, which is the supported way to change them.
derivatives.previewEdge1024The size of the unsaved previews in the admin, when trying a look.

Why not to change them: photos already processed keep the sizes they were made at, so a change leaves a site with a mixture. The skins' layouts and the sharing cards assume these sizes. A larger largeEdge raises memory use for every photo.

internals.formatMegapixels

FormatLimit, in megapixels
avif16
webp60
interlaced png40
heic25

JPEG, ordinary PNG, and TIFF can be read a strip at a time. These four formats must be held whole in memory to open, so they are held to smaller sizes. The limits were measured so that one photo stays under about 450 MB. A larger file in one of these formats is refused with a note to upload a JPEG instead.

HEIC, the format an iPhone saves in, is decoded in a process of its own, measured at about 130 MB plus 11 MB for each megapixel, all of it given back when the photo is done. An iPhone's usual 12 or 24 megapixels fit (24 takes about 400 MB); its 48-megapixel setting does not, on a server this small.

Why not to change them: raising one can crash a 1 GB server in the middle of an upload.

internals.moduleOutputMegapixels

Value: 40. The largest picture a module may produce. A module can make a photo bigger (the film frame adds a border); this stops a faulty or careless one from producing an image that fills memory or disk.

internals.queue

SettingValueWhat it is
queue.maxAttempts3How many times a photo is tried before it is marked failed. A failed photo's page in the library shows the reason and a Try again button, and the uploaded file is kept.

internals.auth: logging in

SettingValueWhat it is
auth.sessionDays30How long a login lasts without being used. Each use renews it for another 30 days, but never beyond 90 days from when the login was made.
auth.maxFailures5Wrong passwords, or wrong setup tokens, allowed from one address…
auth.failureWindowMinutes15…within this many minutes, before that address has to wait.
auth.passwordMinLength12The shortest password accepted, in the setup wizard, in the browser, and by reset-admin.

Why not to change them: these are the site's defences against password guessing. Loosening them makes the one account that controls the site easier to break into.

internals.samples: the sample photos

SettingValueWhat it is
samples.source'https://picsum.photos'Where the 25 sample photographs are downloaded from, when you ask for them.
samples.timeoutSeconds20How long to wait for each one.
samples.giveUpAfter3If this many in a row fail at the start, the service is treated as unreachable and the download stops, so nobody waits through 25 failures.

internals.requirements: what a machine must have

The figures the preflight check uses each time Fotobogen starts. Below a fail figure it refuses to run; below a warn figure it runs and says what to improve.

SettingValueWhat it is
requirements.nodeMajor24The oldest version of Node.js it will run on.
requirements.memoryMbfail: 900, warn: 1900Memory available, in megabytes. In a container, the container's limit counts, not the host's.
requirements.freeDiskMbfail: 500, warn: 2000Free space on the disk holding the data folder, in megabytes.
requirements.platformslinux, darwin (macOS), win32 (Windows)The systems it is tested on. Another one gets a warning, not a refusal.
requirements.architecturesx64, arm64The processors its image and database libraries are built for. Another one is refused.
requirements.linuxFamiliesdebian, ubuntuThe Linux families it is tested on. Another one gets a warning that it is untested.

Why not to change them: the check exists so that an installation never half-works. To start anyway on a machine that fails it, at your own risk, there is a setting for exactly that, below.

Settings that exist only in .env

These are not in fotobogen.config.js, because they are about one start of the app or about Docker, not about the app itself.

SettingWhat it does
FOTOBOGEN_NO_QUESTIONS=1The first start in a terminal asks nothing and uses the defaults. Give it when starting (FOTOBOGEN_NO_QUESTIONS=1 pnpm start), not in .env: once .env exists nothing is asked anyway. (Nothing is ever asked under pm2, in Docker, or from a script.)
NO_COLOR=1Plain text with no colour in the terminal. Give it when starting (NO_COLOR=1 pnpm start), not in .env.
FOTOBOGEN_SKIP_PREFLIGHT=1Starts even when the preflight check fails. At your own risk: the check failed for a reason, and the usual result is a site that runs out of memory or disk while processing a photo. It does not reach a Docker container.
DOMAINDocker quick start only. The domain name Caddy gets an HTTPS certificate for. Left unset, the site is plain HTTP on localhost.
PUID, PGIDDocker only. The user and group that own the files in data. Use what id -u and id -g print; 1000 is the usual first user on Linux.

Every setting at a glance

In the fileDefaultIn .envChange it?
server.port5150PORTYes
server.portAttempts10noneRarely needed
server.host0.0.0.0HOSTYes
server.trustProxyfalseTRUST_PROXYOnly behind your own proxy
server.siteUrlnoneSITE_URLYes, on a public site
server.demoModefalseDEMO_MODEOnly on a demonstration site
dataDir./dataDATA_DIRYes
uploads.maxUploadMb50MAX_UPLOAD_MBYes, with the proxy's limit
uploads.maxMegapixels100MAX_MEGAPIXELSYes, with memory to match
webhooks.allowPrivatefalseWEBHOOKS_ALLOW_PRIVATEOnly for your own network
none (in .env only)not setADMIN_HOSTYes: the admin at an address of its own
none (in .env only)a file in your home folderTWO_STEP_KEY_FILERarely needed
none (in .env only)not setTWO_STEP_KEYOnly to share one authenticator entry between Docker sites
internals.derivativessee abovenoneNo
internals.formatMegapixels16, 60, 40, 25noneNo
internals.moduleOutputMegapixels40noneNo
internals.queue3 attemptsnoneNo
internals.authsee abovenoneNo
internals.samplessee abovenoneNo
internals.requirementssee abovenoneNo

The file itself, with a comment on every value, is fotobogen.config.js.

Back: Your own domain Next: Using Fotobogen