Skip to main content

Configuration

The Docker image includes a binary with flags to configure its modules. This guide lists all available flags so you can fine-tune Gotenberg to your needs.

How To

To set one or more flags, it's necessary to override the Docker image's default command.

For example, with the Docker CLI:

docker run --rm -p "3000:3000" gotenberg/gotenberg:8 gotenberg --my-module-property=foo

Or with Docker Compose:

compose.yaml
services:
# Your other services.

gotenberg:
image: gotenberg/gotenberg:8
command:
- "gotenberg"
- "--my-module-property=foo"
caution

Do not redefine the Gotenberg Docker image default entrypoint, but override the command instead. See this issue for more details.


Alternatively, you can set environment variables that directly correspond to the command-line flags.

For example, with the Docker CLI:

docker run --rm -p "3000:3000" -e MY_MODULE_PROPERTY=foo gotenberg/gotenberg:8

Or with Docker Compose:

compose.yaml
services:
# Your other services.

gotenberg:
image: gotenberg/gotenberg:8
environment:
MY_MODULE_PROPERTY: "foo"

API

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

The following flags allow you to configure the API module:

FlagEnvironment variableDescriptionDefault
--api-portAPI_PORTSet the port on which the API should listen.3000
--api-port-from-envAPI_PORT_FROM_ENVSet the environment variable with the port on which the API should listen - override the default port.None
--api-bind-ipAPI_BIND_IPSet the IP address the API should bind to for incoming connections.0.0.0.0
--api-tls-cert-fileAPI_TLS_CERT_FILEPath to the TLS/SSL certificate file - for HTTPS support.None
--api-tls-key-fileAPI_TLS_KEY_FILEPath to the TLS/SSL key file - for HTTPS support.None
--api-start-timeoutAPI_START_TIMEOUTSet the time limit for the API to start.30s
--api-timeoutAPI_TIMEOUTSet the time limit for requests.30s
--api-body-limitAPI_BODY_LIMITSet the body limit for multipart/form-data requests - it accepts values like 5MB, 1GB, etc.None
--api-root-pathAPI_ROOT_PATHSet the root path of the API - for service discovery via URL paths/
--api-trace-headerAPI_TRACE_HEADERSet the header name to use for identifying requests.Gotenberg-Trace
--api-enable-basic-authAPI_ENABLE_BASIC_AUTHEnable basic authentication - will look for the GOTENBERG_API_BASIC_AUTH_USERNAME and GOTENBERG_API_BASIC_AUTH_PASSWORD environment variables.false
--api-download-from-allow-listAPI_DOWNLOAD_FROM_ALLOW_LISTSet the allowed URLs for the download from feature using a regular expression.All
--api-download-from-deny-listAPI_DOWNLOAD_FROM_DENY_LISTSet the denied URLs for the download from feature using a regular expression.None
--api-download-from-max-retryAPI_DOWNLOAD_FROM_MAX_RETRYSet the maximum number of retries for the download from feature.4
--api-disable-download-fromAPI_DISABLE_DOWNLOAD_FROMDisable the download from feature.false
--api-disable-health-check-loggingAPI_DISABLE_HEALTH_CHECK_LOGGINGDisable health check logging.false
--api-enable-debug-routeAPI_ENABLE_DEBUG_ROUTEEnable debug route.false

Chromium

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

A single Chromium browser manages the conversions in a stateful mode, enabling quicker single conversions. However, due to a lock mechanism, a Chromium browser cannot execute parallel operations.

During periods of heavy load, incoming requests will accumulate in the queue until they are processed, time out, or the queue reaches its maximum capacity. In the latter case, the request will be terminated prematurely.

To maintain performance under a heavy load, consider increasing the number of Gotenberg instances.

caution

Before Gotenberg 8.22.0, the amd64 image used Google Chrome (stable), while other architectures used Chromium. Now all architectures use Chromium.

The following flags allow you to configure the Chromium module:

FlagEnvironment variableDescriptionDefault
--chromium-restart-afterCHROMIUM_RESTART_AFTERNumber of conversions after which Chromium will automatically restart. Set to 0 to disable this feature.10*
--chromium-max-queue-sizeCHROMIUM_MAX_QUEUE_SIZEMaximum request queue size for Chromium. Set to 0 to disable this feature.0
--chromium-auto-startCHROMIUM_AUTO_STARTAutomatically launch Chromium upon initialization if set to true; otherwise, Chromium will start at the time of the first conversion.false
--chromium-start-timeoutCHROMIUM_START_TIMEOUTMaximum duration to wait for Chromium to start or restart.20s
--chromium-allow-file-access-from-filesCHROMIUM_ALLOW_FILE_ACCESS_FROM_FILESAllow file:// URIs to read other file:// URIs.false
--chromium-allow-insecure-localhostCHROMIUM_ALLOW_INSECURE_LOCALHOSTIgnore TLS/SSL errors on localhost.false
--chromium-allow-listCHROMIUM_ALLOW_LISTSet the allowed URLs for Chromium using a regular expression.All
--chromium-deny-listCHROMIUM_DENY_LISTSet the denied URLs for Chromium using a regular expression.^file:(?!//\/tmp/).*
--chromium-ignore-certificate-errorsCHROMIUM_IGNORE_CERTIFICATE_ERRORSIgnore the certificate errors.false
--chromium-disable-web-securityCHROMIUM_DISABLE_WEB_SECURITYDon't enforce the same-origin policy.false
--chromium-incognitoCHROMIUM_INCOGNITOStart Chromium with incognito mode.false
--chromium-host-resolver-rulesCHROMIUM_HOST_RESOLVER_RULESSet custom mappings to the host resolver.None
--chromium-proxy-serverCHROMIUM_PROXY_SERVERSet the outbound proxy server; this switch only affects HTTP and HTTPS requests.None
--chromium-clear-cacheCHROMIUM_CLEAR_CACHEClear Chromium cache between each conversion.false
--chromium-clear-cookiesCHROMIUM_CLEAR_COOKIESClear Chromium cookies between each conversion.false
--chromium-disable-javascriptCHROMIUM_DISABLE_JAVASCRIPTDisable JavaScript.false
--chromium-disable-routesCHROMIUM_DISABLE_ROUTESDisable the routes.false

*Prior to Gotenberg 8.15.2, restarting Chromium resulted in zombie processes.

LibreOffice

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

A single LibreOffice instance manages the conversions in a stateful mode, enabling quicker single conversions. However, due to a lock mechanism, a LibreOffice instance cannot execute parallel operations.

During periods of heavy load, incoming requests will accumulate in the queue until they are processed, time out, or the queue reaches its maximum capacity. In the latter case, the request will be terminated prematurely.

To maintain performance under a heavy load, consider increasing the number of Gotenberg instances.

The following flags allow you to configure the LibreOffice module:

FlagEnvironment variableDescriptionDefault
--libreoffice-restart-afterLIBREOFFICE_RESTART_AFTERNumber of conversions after which LibreOffice will automatically restart. Set to 0 to disable this feature.10
--libreoffice-max-queue-sizeLIBREOFFICE_MAX_QUEUE_SIZEMaximum request queue size for LibreOffice. Set to 0 to disable this feature.0
--libreoffice-auto-startLIBREOFFICE_AUTO_STARTAutomatically launch LibreOffice upon initialization if set to true; otherwise, LibreOffice will start at the time of the first conversion.false
--libreoffice-start-timeoutLIBREOFFICE_START_TIMEOUTMaximum duration to wait for LibreOffice to start or restart.20s
--libreoffice-disable-routesLIBREOFFICE_DISABLE_ROUTESDisable the routes.false

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:8

USER root

RUN apt-get update -qq &&\
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends -t bookworm-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:

EngineMergeSplitFlattenConvert into PDF/A & PDF/UARead/Write metadataName
ExifToolexiftool
PDFtkpdtk
pdfcpupdfcpu
QPDFqpdf
UNOlibreoffice-pdfengine
info

PDFtk and QPDF only supports the split mode pages with unification.

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

FlagEnvironment variableDescriptionDefault
--pdfengines-merge-enginesPDFENGINES_MERGE_ENGINESSet the PDF engines and their order for the merge feature - empty means all.qpdf,pdfcpu,pdftk
--pdfengines-split-enginesPDFENGINES_SPLIT_ENGINESSet the PDF engines and their order for the split feature - empty means all.pdfcpu,qpdf,pdftk
--pdfengines-flatten-enginesPDFENGINES_FLATTEN_ENGINESSet the PDF engines and their order for the flatten feature - empty means all.qpdf
--pdfengines-convert-enginesPDFENGINES_CONVERT_ENGINESSet the PDF engines and their order for the convert feature - empty means all.libreoffice-pdfengine
--pdfengines-read-metadata-enginesPDFENGINES_READ_METADATA_ENGINESSet the PDF engines and their order for the read metadata feature - empty means all.exiftool
--pdfengines-write-metadata-enginesPDFENGINES_WRITE_METADATA_ENGINESSet the PDF engines and their order for the read metadata feature - empty means all.exiftool
--pdfengines-disable-routesPDFENGINES_DISABLE_ROUTESDisable the routes.false
warning

As of Gotenberg 8.13.0, the flag --pdfengines-engines has been deprecated.

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:

FlagEnvironment variableDescriptionDefault
--webhook-enable-sync-modeWEBHOOK_ENABLE_SYNC_MODEEnable synchronous mode for the webhook feature.false
--webhook-allow-listWEBHOOK_ALLOW_LISTSet the allowed URLs for the webhook feature using a regular expression.All
--webhook-deny-listWEBHOOK_DENY_LISTSet the denied URLs for the webhook feature using a regular expression.None
--webhook-error-allow-listWEBHOOK_ERROR_ALLOW_LISTSet the allowed URLs in case of an error for the webhook feature using a regular expression.All
--webhook-error-deny-listWEBHOOK_ERROR_DENY_LISTSet the denied URLs in case of an error for the webhook feature using a regular expression.None
--webhook-max-retryWEBHOOK_MAX_RETRYSet the maximum number of retries for the webhook feature.4
--webhook-retry-min-waitWEBHOOK_RETRY_MIN_WAITSet the minimum duration to wait before trying to call the webhook again.1s
--webhook-retry-max-waitWEBHOOK_RETRY_MAX_WAITSet the maximum duration to wait before trying to call the webhook again.30s
--webhook-client-timeoutWEBHOOK_CLIENT_TIMEOUTSet the time limit for requests to the webhook.30s
--webhook-disableWEBHOOK_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:

FlagEnvironment variableDescriptionDefault
--prometheus-collect-intervalPROMETHEUS_COLLECT_INTERVALSet the interval for collecting modules' metrics.1s
--prometheus-namespacePROMETHEUS_NAMESPACESet the namespace of modules' metrics.gotenberg
--prometheus-disable-collectPROMETHEUS_DISABLE_COLLECTDisable the collect of metrics.false
--prometheus-disable-route-loggingPROMETHEUS_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:

FlagEnvironment variableDescriptionDefault
--log-formatLOG_FORMATSpecify the format of logging. Options include auto, json, or text.auto
--log-levelLOG_LEVELChoose the level of logging detail. Options include error, warn, info, or debug.info
--log-fields-prefixLOG_FIELDS_PREFIXPrepend a specified prefix to each field in the logs.None
--log-enable-gcp-fieldsLOG_ENABLE_GCP_FIELDSEnable Google Cloud Platform fields - namely: time, message, severity.None
warning

As of Gotenberg 8.19.0, the flag --log-enable-gcp-severity has been deprecated in favor of --log-enable-gcp-fields.

Graceful Shutdown

To ensure running tasks have enough time to complete, Gotenberg waits for a specific duration before initiating the shutdown process.

The following flag allows you to configure this duration:

FlagEnvironment variableDescriptionDefault
--gotenberg-graceful-shutdown-durationGOTENBERG_GRACEFUL_SHUTDOWN_DURATIONSet the graceful shutdown duration.30s
info

For Gotenberg versions prior to 8.21.0, when using the webhook feature, make sure this duration is equal to or longer than the API timeout. This ensures that all asynchronous processes finish before Gotenberg begins its shutdown sequence.

Hide Banner

The following flag allows you to hide the startup banner with:

FlagEnvironment variableDescriptionDefault
--gotenberg-hide-bannerGOTENBERG_HIDE_BANNERHide the banner.false

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:8

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:8

USER root

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

USER gotenberg

Via .deb packages

FROM gotenberg/gotenberg:8

USER root

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

USER gotenberg

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:8

USER root

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

USER gotenberg
info

Since Gotenberg 8.21.0, the image also supports arbitrary user IDs (OpenShift).