Skip to content

HTTP and Domain

Use http-server to run nginx. Use domain to generate nginx config for host names and routes.

type: http-server
http_port: 80
https_port: false
access_log:
max_size_mb: 200
max_files: 1

Fields:

FieldRequiredDefaultPurpose
imageNodocker.io/library/nginx:stablenginx image.
http_portNo80Host port mapped to container port 80.
https_portNofalseHost port mapped to container port 443. Use false or omit it to disable HTTPS.
access_log.max_size_mbNo200Access log rotation threshold in MiB.
access_log.max_filesNo1Number of archived access log files to keep.
type: domain
server: nginx
hosts: ["example.com", "www.example.com"]
routes:
- kind: reverse_proxy
location: /
target: ${api:url}

Fields:

FieldRequiredPurpose
serverYesThe http-server unit that serves this domain.
hostsYesHost names for the nginx server_name.
proxyNoTrusted proxy settings for real client IPs.
custom_configNoRaw nginx config inserted inside the server block.
routesNoRoutes served under this domain. See Routes.

Routes describe how nginx handles requests inside a domain.

Common fields:

FieldRequiredPurpose
kindYesRoute type. Supported values are reverse_proxy, uwsgi, fastcgi, serve_files, redirect, and return.
locationYesnginx location path or regex. Regex locations must be wrapped in single quotes, for example location: '~ \.php$'.
routes:
- kind: reverse_proxy
location: /
target: ${api:url}
routes:
- kind: uwsgi
location: /
target: ${django:socket}
routes:
- kind: fastcgi
location: /
target: ${phpfpm:socket}

Use target for a FastCGI upstream such as unix:/run/php-fpm.sock or 127.0.0.1:9000. References like ${phpfpm:socket} are supported.

Serve files exported from a static or app unit:

routes:
- kind: serve_files
location: /static
root: ${django:export}

Serve a single-page app:

routes:
- kind: serve_files
location: /
root: ${site:export}
spa: true
routes:
- kind: redirect
location: /old
target: https://example.com$request_uri

Redirects use HTTP 302 by default. Set permanent: true to use HTTP 301:

routes:
- kind: redirect
location: /moved
target: https://example.com/new
permanent: true

target is passed to nginx as a literal value. It does not resolve ${unit:key} references.

routes:
- kind: return
location: /health
status: 204

Return a status code with a body:

routes:
- kind: return
location: /gone
status: 410
body: gone

body is optional and is returned as a literal string.

Use this when nginx is behind a proxy and you need the real client IP.

Cloudflare:

proxy:
type: cloudflare

Fastly:

proxy:
type: fastly

Custom:

proxy:
type: custom
header: X-Forwarded-For
proxies:
- 192.0.2.10

custom_config is inserted inside the generated server block.

custom_config: |
client_max_body_size 50m;
add_header X-Frame-Options DENY always;

Keep this short. Use it for settings that dpl does not model yet. dpl inserts this value as raw nginx config and does not validate it.

Routes also accept custom_config, allowing dpl to inject route-specific settings directly into the generated location blocks.

routes:
- kind: fastcgi
location: '~ \.php$'
target: ${phpfpm:socket}
custom_config: |
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

Nginx’s logs are written to the http-server state directory <base>/state/<unit>/log/:

  • runtime.log is an error log in CRI k8s-file format.
  • access.log is an access log in JSONL format.

Optional config for access log:

type: http-server
access_log:
max_size_mb: 200
max_files: 1