Skip to main content
Version: 7.x

Configuration

The Docker image internally employs a binary that offers flags to configure its multiple modules. This guide contains a comprehensive list of flags that you can use to fine-tune Gotenberg according to your specific requirements.

API

The API module is an HTTP/1 and HTTP/2 (H2C) server.

The following flags allow you to configure the API module:

FlagDescriptionDefault
--api-portSet the port on which the API should listen.3000
--api-port-from-envtSet the environment variable with the port on which the API should listen - override the default port.None
--api-timeoutSet the time limit for requests.30s
--api-root-pathSet the root path of the API - for service discovery via URL paths./
--api-trace-headerSet the header name to use for identifying requests.Gotenberg-Trace
--api-disable-health-check-loggingDisable health check logging.false

Chromium

The Chromium module interacts with the Chromium browser to convert HTML documents to PDF.

The following flags allow you to configure the Chromium module:

FlagDescriptionDefault
--chromium-allow-file-access-from-filesAllow file:// URIs to read other file:// URIs.false
--chromium-allow-insecure-localhostIgnore TLS/SSL errors on localhost.false
--chromium-allow-listSet the allowed URLs for Chromium using a regular expression.All
--chromium-deny-listSet the denied URLs for Chromium using a regular expression.^file:///[^tmp].*
--chromium-ignore-certificate-errorsIgnore the certificate errors.false
--chromium-disable-web-securityDon't enforce the same-origin policy.false
--chromium-incognitoStart Chromium with incognito mode.false
--chromium-failed-starts-thresholdSet the number of consecutive failed starts after which the module is considered unhealthy.5
--chromium-host-resolver-rulesSet custom mappings to the host resolver.None
--chromium-proxy-serverSet the outbound proxy server; this switch only affects HTTP and HTTPS requests.None
--chromium-disable-javascriptDisable JavaScript.false
--chromium-disable-routesDisable the routes.false
info

It starts a dedicated Chromium instance for each conversion.

info

If --chromium-failed-starts-threshold=0, there is no health check for this module.

caution

The amd64 Docker image uses Google Chrome stable, while other architectures use an earlier version of Chromium.

LibreOffice

The LibreOffice module interacts with LibreOffice to convert numerous documents to PDF, thanks to unoconv.

The following flags allow you to configure the LibreOffice module:

FlagDescriptionDefault
--libreoffice-disable-routesDisable the route.false
--uno-listener-start-timeoutTime limit for starting the LibreOffice listener.10s
--uno-listener-restart-thresholdConversions limit after which the LibreOffice listener is restarted.10

Stateful or Stateless

By default, a long-running LibreOffice listener handles the conversions. This stateful mode allows for faster unitary conversion, but there is a lock mechanism as a single LibreOffice listener cannot perform parallel operations.

In other words, under heavy load, you should consider scaling up your number of Gotenberg instances or switch the LibreOffice module to a stateless mode with --uno-listener-restart-threshold=0 (i.e., a dedicated LibreOffice listener per conversion).

info

Gotenberg restarts the long-running LibreOffice listener if it is unhealthy before and after a conversion.

info

If --uno-listener-restart-threshold=0 (i.e., stateless mode), there is no health check for this module.

caution

The --uno-* properties also impact the performance of the UNO PDF engine (see PDF Engines).

Switch Language

By default, LibreOffice uses the English language when it converts documents to PDF. You may override this behavior by building your own Docker image.

For instance, with the German language:

FROM gotenberg/gotenberg:7

USER root

RUN apt-get update -qq &&\
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t bullseye-backports libreoffice-l10n-de &&\
sed -i '/de_DE.UTF-8/s/^# //g' /etc/locale.gen &&\
locale-gen &&\
# Cleanup.
# Note: the Debian image does automatically a clean after each install thanks to a hook.
# Therefore, there is no need for apt-get clean.
# See https://stackoverflow.com/a/24417119/3248473.
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

ENV LANG de_DE.UTF-8
ENV LANGUAGE de_DE:de
ENV LC_ALL de_DE.UTF-8

USER gotenberg

PDF Engines

The PDF Engines module gathers all engines that can manipulate PDF files. It calls each engine until one successfully handles a task. A PDF engine is an external tool that Gotenberg leverages to perform a specific task, such as merging PDF files.

Currently, Gotenberg supports the following PDF engines:

EngineMergeConvert into PDF/AName
PDFtkpdtk
PDFcpupdcpu
QPDFqpdf
UNOuno-pdfengine

The following flags allow you to configure the PDF Engines module:

FlagDescriptionDefault
--pdfengines-enginesSet the PDF engines and their order.All
--pdfengines-disable-routesDisable the routes.false
info

For instance, the value "pdftk,uno-pdfengine" selects PDFtk as the first engine, and UNO as the second.

Webhook

The webhook feature enables Gotenberg to upload the output file originating from multipart/form-data routes to a selected destination.

The following flags allow you to configure the Webhook module:

FlagDescriptionDefault
--webhook-allow-listSet the allowed URLs for the webhook feature using a regular expression.All
--webhook-deny-listSet the denied URLs for the webhook feature using a regular expression.None
--webhook-error-allow-listSet the allowed URLs in case of an error for the webhook feature using a regular expression.All
--webhook-error-deny-listSet the denied URLs in case of an error for the webhook feature using a regular expression.None
--webhook-max-retrySet the maximum number of retries for the webhook feature.4
--webhook-retry-min-waitSet the minimum duration to wait before trying to call the webhook again.1s
--webhook-retry-max-waitSet the maximum duration to wait before trying to call the webhook again.30s
--webhook-client-timeoutSet the time limit for requests to the webhook.30s
--webhook-disableDisable the webhook feature.false

Prometheus

The Prometheus module collects metrics from other modules and exposes an HTTP endpoint that can be scraped by Prometheus.

The following flags allow you to configure the Prometheus module:

FlagDescriptionDefault
--prometheus-collect-intervalSet the interval for collecting modules' metrics.1s
--prometheus-namespaceSet the namespace of modules' metrics.gotenberg
--prometheus-disable-collectDisable the collect of metrics.false
--prometheus-disable-route-loggingDisable the route logging.false

Logging

Gotenberg employs a logger that generates structured logs. Structured logs are formatted in a standardized, machine-readable way, making them extremely beneficial for centralized log management.

The following flags allow you to configure the logger:

FlagDescriptionDefault
--log-formatSpecify the format of logging. Options include auto, json, or text.auto
--log-levelChoose the level of logging detail. Options include error, warn, info, or debug.info
--log-fields-prefixPrepend a specified prefix to each field in the logs.None

Graceful Shutdown

To ensure running tasks have sufficient time to complete, Gotenberg waits for a specific duration before initiating the shutdown process. It may stop earlier if all tasks have completed.

The following flag allows you to configure this duration:

FlagDescriptionDefault
--gotenberg-graceful-shutdown-durationSet the graceful shutdown duration.30s

Docker Image

Fonts

The default Docker image is pre-packaged with an extensive assortment of fonts, including Asian ones. If your application requires additional or specific fonts not included in this collection, you'll need to construct a tailored Docker image to incorporate those fonts.

Via .tff files

FROM gotenberg/gotenberg:7

USER root

COPY /local/path/to/{font}.ttf /usr/local/share/fonts/{font}.ttf

USER gotenberg

Or, if you have many fonts:

FROM gotenberg/gotenberg:7

USER root

COPY /local/path/to/fonts/* /usr/local/share/fonts/

USER gotenberg

Via .deb packages

FROM gotenberg/gotenberg:7

USER root

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends my-fonts-package

USER gotenberg

info

You could also mount a volume containing your fonts to /usr/local/share/fonts/ as suggested in this comment.

Ownership

The Docker image employs a specific non-root user, named gotenberg, with a User ID (uid) and Group ID (gid) of 1001. If you want to change these identifiers, you will have to build a custom Docker image:

FROM gotenberg/gotenberg:7

USER root

RUN usermod -u {uid} -g {gid} gotenberg

USER gotenberg