Core
Ingress, routing & tunnels
The complete upstream guide to ingress, routing & tunnels, synchronized with the product repository.
Product v0.22.0 · Complete source guide
Ingress, Routing & Cloudflare Tunnels
NineDeploy embeds Traefik as its reverse proxy and ingress controller, providing automated TLS certificates, custom middlewares, and secure tunneling.
🌐 1. Dynamic Ingress Architecture
- Automatic Route Generation: Every deployed service is assigned dynamic Traefik routers based on its domain configurations.
- Health-Gated Routing: Traefik only sends traffic to containers marked healthy by NineDeploy's health monitoring loop.
- WebSocket & HTTP/2 Support: Native bidirectional streaming for WebSockets, SSE, and HTTP/2 multiplexing.
Automatic URLs (0.16.1)
A service can get a URL of its own the moment it deploys, before any domain is set up. Configure it under Settings → Security → Automatic URLs (operator only) or with PUT /v1/settings/auto-url:
| Mode | A service named shop gets | DNS you set up | TLS |
|---|---|---|---|
Free test URLs (sslip) | http://shop.203.0.113.10.sslip.io | none — sslip.io answers *.<ip>.sslip.io with that address | plain HTTP, meant for testing |
Your wildcard domain (domain) | https://shop.apps.example.com | one wildcard record, *.apps.example.com → the server | ACME per name, or one wildcard certificate via DNS-01 |
Off (off) | only the domains you add | — | — |
- The URL is added when the service's deploy goes live. Generate URL on the service's Network tab (
POST /v1/services/:id/domains/auto) adds it at once. - A service pinned to a node uses the node's address in sslip mode. A node registered by hostname has no sslip.io name.
- Each service's automatic name is reserved for it: another tenant's claim on
shop.<zone>is refused, as is a wildcard over the zone. Names inside the zone need no DNS proof. NINEDEPLOY_WILDCARD_DOMAINstill works exactly as before and wins over the setting.- Upgrades: an upgraded panel stays
off. A fresh install turns on sslip.io when the installer recorded a public IPv4 (NINEDEPLOY_PUBLIC_URL=http://<ip>:3000). Detect asks a public echo service for the address, and only when clicked.
Path routing
A domain can route only a path prefix to a service, so several services share one host: app.example.com → the web service, app.example.com/api → the API. Type the path next to the hostname on the service's Network tab (pasting https://app.example.com/api fills both), or send path to POST /v1/services/:id/domains.
- The router matches
Host(…) && PathPrefix(/api); a longer rule wins over the bare host. - The request keeps its path: the API service receives
/api/users, not/users, so it must serve under the prefix. - Every service already routing the host must be one you can manage (
memberon it); you cannot stack a path on another tenant's host.
Redirect rules (0.16.1)
Each domain can carry up to 10 redirect rules (Network tab → the domain's Security panel → Redirects, or redirects on PATCH /v1/services/:id/domains/:domainId). A rule is a regular expression matched against the full request URL, a target, and whether the redirect is permanent (301/308) or temporary (302/307):
| Pattern | Target | Effect |
|---|---|---|
^https?://example\.com/blog/(.*) | https://blog.example.com/${1} | moves the blog to its own host, keeping the path |
^https?://example\.com/old-pricing$ | https://example.com/pricing | one page renamed |
- Rules become Traefik
redirectRegexmiddlewares and run in order, before the domain's Basic Auth, headers, IP allowlist and rate limit. - Traefik uses Go's RE2: lookahead, lookbehind and backreferences are refused when a rule is saved. A stored rule RE2 would refuse is skipped when the config is written, so one bad rule never takes routing down.
- A target that matches its own pattern makes browsers loop; anchor the pattern (
$) or make the target fall outside it. - The www → apex redirect is the domain's own toggle; it is not one of these rules.
🔒 2. Let's Encrypt SSL Certificates
HTTP-01 Challenge: Automatic SSL issuance for apex and subdomains on port 80/443.
DNS-01 Challenge: Automatic wildcard SSL certificates (
*.yourdomain.com) via Cloudflare, DigitalOcean, Hetzner, Linode, Gandi or DuckDNS DNS API integration.Auto-Renewal: Traefik automatically renews certificates 30 days before expiration.
HTTP → HTTPS: a domain with SSL on also answers plain HTTP with a redirect to HTTPS (a temporary one, so turning SSL off takes effect). The panel domain does the same once an ACME email is configured.
Automatic DNS records: NineDeploy can create a domain's DNS record when the domain goes live, and delete it with the domain. Only one provider is active at a time; saving one replaces the previous one. The supported providers are below.
The record is an A record when the target is an IPv4 address and an AAAA record for IPv6. Otherwise it is a CNAME. The target is the record content from the Cloudflare card, or this host's public IP. A record that already exists for the host is left unchanged and reported as a failure. Cloudflare records are made by the domain routes and also cover the www companion. The other providers are driven by the
domain-presetsplugin, which publishesdomain.preset.appliedanddomain.preset.failedevents.Provider Configured on Credentials Cloudflare Settings → Integrations → Cloudflare DNS records API token with Zone.DNS edit Namecheap Settings → Integrations → Namecheap API user, API key, whitelisted IPv4 DNSimple dns_records_provider=dnsimple+dns_records_token_encrypted+dns_records_account_idAPI token, account id Amazon Route 53 (G3.5) Settings → Integrations → DNS records: Route 53, OVH, Porkbun, Hetzner IAM access key allowed route53:ListHostedZonesandroute53:ChangeResourceRecordSets; private hosted zones are skippedOVHcloud (G3.5) same card region (eu, ca, us), application key and secret, consumer key granted GET/POST/DELETE on /domain/zone/*; every change is followed by a zone refreshPorkbun (G3.5) same card pk1_andsk1_key pair; API access must be switched on per domain; TTL floor 600 sHetzner DNS (G3.5) same card Hetzner Cloud API token (Read & Write) of the project holding the zones; uses the Cloud API, not the retired dns.hetzner.com API On the G3.5 card, List zones shows the zones the saved credentials can see. The credentials are stored encrypted in the
dns_records_credentials_encryptedsetting and are re-encrypted by master-key rotation. API:GET/PUT/DELETE /v1/settings/dns-records/providerandPOST /v1/settings/dns-records/provider/test.HTTP/3 (0.16.1, opt-in): Traefik → Overview → HTTP/3 publishes
443/udpso browsers can use QUIC. The static config has always declaredhttp3onwebsecure, but without the UDP port browsers could never reach it. Turning it on or off recreates the panel host's Traefik once (about a second of refused connections); a failed recreate puts the switch and the previous container back and answers 502. Off, the container is exactly the 0.16.0 one, so an upgrade does not recreate it. Open UDP 443 in the cloud provider's firewall as well. Node proxies are unchanged. API:GET/PUT /v1/traefik/http3.
🛡️ 3. Middlewares & Rate Limiting
Apply security middlewares directly from the dashboard:
- IP Allowlisting / Denylisting: Restrict internal admin services to VPN/office CIDRs.
- Basic Auth: Add an extra authentication layer in front of legacy web services. Passwords are stored and rendered as APR1 htpasswd hashes (
user:passwordis hashed on save; a pasteduser:$apr1$…/ bcrypt entry is kept as is), and are hidden from viewer seats. - Custom Headers & CORS: Inject HSTS, Content-Security-Policy, and CORS headers automatically.
A domain per compose service (G2.1)
Every domain of a compose stack routes to the stack's main service unless it names another one. Pick it in the domain's row under Service → Network → Domains, or with PUT /v1/domains/:id/compose-route and { "route": { "service": "admin-ui", "port": 8080 } }. { "route": null } routes to the main service again.
How it routes
- Traefik already joins the stack's default network, so it reaches the service as
ndcmp-<slug>-<service>-1on the port you give. The service must be on that default network. - For an inline stack, the service must be one the compose file declares.
- A route whose container name another stack could also own is refused when saved, and falls back to the main service if such a stack appears later. For example,
x-webin stackshopandwebin stackshop-xwould both bendcmp-shop-x-web-1. - The next deploy sets
SERVICE_FQDN_<SERVICE>(the host) andSERVICE_URL_<SERVICE>(scheme, host and path) for each routed service, unless the stack already sets them.<SERVICE>is the name in upper case with other characters as_.
Storage: no migration is needed; it is a settings row, compose_route:<domainId>, read with the other routing overrides in one query.
Maintenance mode and custom error pages (G2.2)
Both live under Service → Settings → Maintenance mode, or in the API as PUT /v1/services/:id/maintenance and PUT /v1/services/:id/error-pages. They work for services on the panel host and for services on a node (see On a node below), but not for a service with fan-out nodes. While either one is on, the service cannot gain a fan-out node, and it can move only to a node that serves the pages itself (move_panel_host_only otherwise).
Maintenance mode
- While it is on, every domain of the service answers a 503 page with
Retry-After, served by the panel. The page shows the title and message you set. - The path and query are kept, so the panel can tell which service the visitor asked for.
- Addresses on the bypass list still reach the app, so the team can check a release before switching maintenance off. Matching uses Traefik's
ClientIP, which is the connecting address. Behind a CDN, list the address the CDN connects from. - A stopped service in maintenance still shows the page.
- In the dynamic config, the service's routers point at the panel with an
addPrefixof/_nd/maintenance/<id>. Each domain gets a<router>_bypasstwin with aClientIP(...)rule. Its rule is longer, so it wins.
Custom error pages
- HTML for 502, 503 and 504, at most 64 KiB each.
- Traefik's
errorsmiddleware fetches the page from the panel at/_nd/errors/<id>/{status}when the app answers one of those codes or cannot be reached. The visitor gets that status with your HTML. - A status left empty keeps the default page.
Shared rules
- Saving panel sign-in, maintenance mode or custom error pages succeeds only after the proxy acknowledges its configuration. An apply failure restores the previous setting and routing and returns
502 proxy_setting_unapplied. If restoration cannot be confirmed, reads and writes report503 proxy_setting_unconfirmedand the UI shows an unconfirmed routing state. Retry once the proxy is available. A durable rollback record survives a panel crash; boot and the five-minute proxy watchdog retry restoration. A successful save does not mean future proxy availability is guaranteed. - The panel serves a page only when the request's Host header is one of the service's active domains, and never on the panel's own domain. Custom HTML never runs on another origin.
- On the panel host, both need Traefik to reach the panel, the same check scale-to-zero uses.
- No migration is needed: they are settings rows,
maintenance:<id>anderror_pages:<id>.
On a node (P2)
- A node's proxy cannot reach the panel, so the node serves the pages itself. The agent runs a small page server,
ninedeploy-pages, from its own image, on the node proxy's network. It runs read-only, as nobody, without a published port. - The panel renders every page and sends it to the agent, one file per service under
.agent-proxy/pages/next to the node proxy's config. The page server mounts that directory read-only. - On each sync, the panel writes the pages and then makes sure the page server answers. Only after that does it give the node's proxy a config that routes to the page server. When that fails, the node keeps routing the service to the app and the sync logs why. A save counts only when its own sync put the service's pages on the node. Otherwise (the page server failed, the node did not answer, or its routing write was refused) the panel puts the previous value back and confirms both its routing and any restored page before answering
502 node_pages_unapplied. If that restoration cannot be confirmed, the response and later reads are503 proxy_setting_unconfirmed; boot and the proxy watchdog retry it. An older successful pages sync does not certify restoration. - The page server applies the same Host rule as the panel. One server holds the pages of every service on the node, so a service's page is never served on another service's domain.
- Maintenance wins over scale to zero: a sleeping node service in maintenance answers the maintenance page and is not woken. A bypass address still reaches it through the wake catcher, which wakes it.
- The node's agent must be v0.18.27 or newer and run as the
ninedeploy-agentcontainer.NINEDEPLOY_AGENT_NODE_PAGES=off(orNINEDEPLOY_AGENT_CONTAINER_MUTATIONS=off) turns it off. Otherwise saving answers422 node_agent_outdatedor403 node_feature_disabled, and nothing is saved. - A node with no page to serve gets no page server, and its sync makes no extra agent call.
- Earlier node acceptance on a node DinD running the agent the documented way (see current status for the scope of newer checks):
- maintenance answered 503 with the message and
Retry-Afterthrough the node's proxy; - a bypass address reached the app;
- with the app container stopped, the custom 502 page was served;
- the page server answered 404 for a foreign Host;
- switching maintenance off brought the app back;
- a removed page server was started again at the next change;
- with the node's switch off, the save was refused and nothing was saved.
- maintenance answered 503 with the message and
Checked on Traefik 3:
- The error page request keeps the visitor's Host and the original 502.
- A client in the bypass range reaches the app.
- Everyone else gets
/_nd/maintenance/5/cart?x=1at the panel.
Panel sign-in in front of an app (forward auth, G2.3)
Any domain of a service on the panel host can require panel sign-in. Turn it on under Service → Settings → Panel sign-in, or with PUT /v1/domains/:id/forward-auth and { "forwardAuth": { "minRole": "viewer" } }. No extra container runs: Traefik's forwardAuth middleware asks the panel about every request. It is the first middleware on the domain's router.
How a visitor gets in
- Without a valid session cookie, a browser is redirected to the panel's
/forward-authpage. The domain sets a short-livedstatecookie on the way. API clients get401. - Signed in on the panel, with 2FA and every other panel check, the page calls
POST /v1/forward-auth/grant. The answer is a one-time code, valid for 60 seconds, bound to the user, the domain, the return URL and that state. - The browser opens
<domain path>/_nd/fa/callback?code=…on the app's own domain. The panel spends the code there, but only together with the matchingstatecookie, so nobody can sign a visitor in as someone else. It then sets the domain's session cookie (HttpOnly, SameSite=Lax, 12 hours) and sends the visitor back to where they were going.
After sign-in
- Each request checks the cookie's signature, the domain and the user.
- It also checks the user's token version, so Sign out everywhere ends access, and their role on the service against
minRole. The result is cached for 30 seconds. - The app receives the user's email in
X-Forwarded-User.
Limits
- The return URL must be on the protected domain, so the flow is never an open redirect.
- The session cookie only works for its own domain id and host.
- Panel-host services only, not one that also runs on nodes, and Traefik must reach the panel (the same check scale-to-zero uses).
- While a domain is protected, its service cannot move to a node or gain a fan-out node (
move_panel_host_only). - A domain transfer clears the domain's panel sign-in and its compose route (G2.1). Both described the old service; the recipient sets them again.
Failing closed
- A node's proxy never routes a protected domain.
- A settings row that cannot be read makes the verify endpoint answer 403.
- A failed read of the protected domains stops the config render, so the last config stays.
- No migration is needed: it is a settings row,
forward_auth:<domainId>.
🚇 4. Cloudflare Tunnels Integration
Deploy services on private servers, home labs, or NAT-restricted environments without opening public ports or configuring firewall port-forwarding.
- Secure outbound connections to the Cloudflare Edge network.
- DDoS mitigation and global anycast routing.
🧾 5. Domain claim limits
Operators can tune how domains are claimed with PUT /v1/settings/domain-policy (instance operators are exempt from the caps; 0 disables a limit):
maxOwnZoneDomainsPerService(default 50): domains one service may hold inside the instance's own wildcard zone, which need no DNS proof. Existing domains are never removed.maxDomainCreatesPerHour(default 30): domains one account may add per rolling hour.pendingExpiryDays(default 30): unverified domains are removed after this many days. A claimant who proves a hostname another service holds only as unverified can take it over: the add request explains the TXT record to publish.
📁 6. The dynamic config directory (0.14)
From 0.14 the panel's Traefik reads a directory instead of one file. The static config (<data>/traefik/traefik.yml) says providers.file.directory: /etc/traefik/dynamic with watch: true, and <data>/traefik/dynamic/ holds up to three files. Each is written atomically with mode 0600:
| File | Contents | Present when |
|---|---|---|
ninedeploy.yml | The generated routes, the same content dynamic.yml held before 0.14 | Always |
certificates.yml | Uploaded certificates, inline (section 8) | At least one valid certificate is uploaded |
custom.yml | The operator's custom dynamic config (section 7) | A custom config is saved |
The first 0.14 boot recreates ninedeploy-traefik once, through the same guarded path every static change uses: the image is pulled before the old container is removed, and liveness is checked afterwards. Before the recreate, the panel copies the legacy <data>/traefik/dynamic.yml to dynamic/ninedeploy.yml, so the new container starts with every existing route and there is no 404 window. The legacy file stays on disk and is no longer written. If the recreate fails (for example, the image pull fails), the old container keeps serving dynamic.yml, and route writes are mirrored into it until a later recreate succeeds.
Remote nodes. Node proxies use the same directory provider. Before 0.14 they loaded no routes at all: their static config pointed at /etc/traefik/dynamic.yml, but the agent wrote dynamic/ninedeploy.yml. Each node recreates its proxy once after the upgrade and then serves its routes. The custom config stays panel-only in 0.14. Uploaded certificates are sent to a node inline in its generated file, and only for hostnames that node routes. The agent caps a node's dynamic config at 1 MiB, so the panel warns once uploaded certificates pass about 512 KiB.
The Traefik page (GET /v1/traefik/config) reads dynamic/ninedeploy.yml and lists what custom.yml defines separately, under custom.
✏️ 7. Custom dynamic config
Operators can add their own routers, middlewares, services and TLS options next to the generated ones: Traefik → Custom config, ninedeploy proxy config get|validate|set|clear, or the API:
| Route | Purpose |
|---|---|
GET /v1/traefik/custom-config | {content, sha256, updatedAt, updatedBy, status: none|applied|rejected, lastError} |
POST /v1/traefik/custom-config/validate | {ok, errors[], warnings[]}; changes nothing |
PUT /v1/traefik/custom-config | {content}: validate, preflight, write |
DELETE /v1/traefik/custom-config | Remove the file and the stored versions |
All four are operator-only. Fine-grained API tokens are refused: a custom router could take over another tenant's hostname.
Rules (a violation is a 400 with errors: [{path, message}]):
- UTF-8, no NUL, at most 256 KiB, at most 50 000 YAML nodes. YAML aliases (
*name) and merge keys (<<) are refused. Keys are matched case-insensitively, as Traefik reads them, soRoutersandrouterscount as the same key. - Top-level keys:
http,tcpandtls.optionsonly.udp,tls.certificatesandtls.storesare refused; upload certificates instead (section 8). - Sections:
http.routers,http.middlewares,http.services,http.serversTransports,tcp.routers,tcp.services,tcp.middlewares. - Every name you define starts with
custom-orcustom_(^custom[-_][A-Za-z0-9_-]{1,100}$). Generated names (<slug>_<id>,svc_*,mw_*,ninedeploy_panel*) can therefore never collide with yours. You may reference a generated service or middleware; you get a warning, because it can be renamed when its service changes. - Routers:
entryPointswithinwebandwebsecure(TCP routers:websecureonly, and they must list it).prioritybelow 100000, the panel router's.tls.certResolvermay only beletsencrypt, and only when an ACME email is set. - These keys are refused anywhere:
plugin,certFile,keyFile,rootCAs,ca,caFiles. No file on the host can be named from here. {{ … }}is escaped before Traefik reads the file, so Go templates cannot read the environment (for example, a DNS provider token).
Saving. A PUT that passes the rules is loaded first by a throwaway Traefik (--network none, read-only, the current ninedeploy.yml and certificates.yml beside it, about 5 seconds). If that Traefik reports a file-provider error, the answer is 422 (custom_config_refused) and nothing is written. If Docker cannot run it, the answer is 503 (traefik_validation_unavailable) and nothing is saved. Otherwise the file is written, and the live Traefik's log is watched for about 4 seconds. If Traefik still rejects the file, the panel restores the last good version (or removes the file) and answers 422 (custom_config_rejected, audited as traefik.custom_config.rejected). Problems below the file level, such as a router naming a middleware that does not exist, come back as warnings and do not block the save.
This is strict for a reason: in directory mode, one file Traefik cannot decode freezes every dynamic update, including the generated routes. The preflight is the main guard. The post-write log check is best-effort, because Traefik's log wording changes between versions.
Storage. The content is stored encrypted in the database (settings traefik_custom_config_encrypted and traefik_custom_config_last_good_encrypted; the status is in traefik_custom_config_status). The database is the source of truth: every boot rewrites custom.yml from the last good version. Saves and clears are audited as traefik.custom_config.save and traefik.custom_config.clear, with the sha256, never the content.
Example:
http:
middlewares:
custom-hsts:
headers:
stsSeconds: 31536000
stsIncludeSubdomains: true
routers:
custom-status:
rule: "Host(`status.example.com`)"
entryPoints: [websecure]
service: custom-status
tls: {}
services:
custom-status:
loadBalancer:
servers:
- url: "http://10.0.0.20:8080"🔐 8. Uploaded certificates
Bring your own certificate (a commercial or internal-CA certificate, or a wildcard you manage elsewhere): Traefik → Certificates, ninedeploy certificates custom list|upload|replace|delete, or GET/POST /v1/traefik/certificates/custom and PUT/DELETE /v1/traefik/certificates/custom/:id. Operator-only, for the same reason as the custom config: a wildcard certificate would let a member take over other tenants' TLS.
What an upload must be (otherwise 400 invalid_certificate):
- A PEM chain with the leaf first (at most 64 KiB), and its private key (at most 16 KiB). The key must match the leaf and must not be passphrase-protected.
- Key types: RSA of 2048 bits or more, ECDSA P-256 or P-384, or Ed25519.
- The leaf must not have expired. Its hostnames come from the SAN DNS entries, or from the CN when there is no SAN at all.
- At most 100 certificates, and each certificate (by sha256 fingerprint) only once (409).
The chain is stored as is; the key is encrypted with the master key. A key that no longer decrypts (a lost master key) is skipped when rendering, and audited once; it never breaks the routes.
When a certificate is used. An SSL domain whose every hostname is covered by a valid uploaded certificate is rendered with tls: {} and no certResolver, so Traefik serves the uploaded certificate from certificates.yml. Coverage means an exact name or a single-label wildcard (*.example.com covers app.example.com, not a.b.example.com). A domain with a www redirect needs both names covered. The panel domain follows the same rule. Expired certificates are never served, so a domain they covered falls back to ACME (or to Traefik's default certificate without an ACME email).
Interplay with Let's Encrypt. Nothing changes until a covering certificate is uploaded: every other domain keeps certResolver: letsencrypt (or tls: {} without an ACME email). Deleting the certificate puts the resolver back on the next render. Not verified yet: which certificate Traefik prefers when acme.json already holds an ACME certificate for the same host. If a covered domain keeps serving its ACME certificate, remove the domain and add it again.
Inventory and alerts. Uploaded certificates appear in the certificate inventory with their real issuer and subject, source: static and autoRenew: false, and they feed the cert-expiry alert metric. Renew them yourself with replace. Uploads, replacements and deletions are audited as traefik.certificate.upload, .replace and .delete, with the fingerprint and hostnames, never the PEM.
Panel certificates shared with node proxies (G5.7)
Each node proxy normally requests its own Let's Encrypt certificates. That breaks down in two cases:
- A domain points at several ingress hosts, such as fan-out targets behind round-robin DNS. An HTTP-01 challenge for one node can land on another.
- Every node asks for the same wildcard. Let's Encrypt allows 5 duplicate certificates a week, which many nodes use up quickly.
With sharing on, a node proxy gets the panel's own ACME certificates inline, the same way uploaded certificates reach it. It gets only the certificates covering hosts that node routes, and an uploaded certificate for a host always wins. The node's Traefik then serves the shared certificate and skips ACME for the hosts it covers. This was checked against Traefik 3: a covered host logged No ACME certificate generation required, and an uncovered one still went to ACME.
- Turn it on with
PUT /v1/traefik/certificates/shared{ "enabled": true }(operator).GETreads it. Changing it re-renders every proxy and is audited astraefik.certificate.share. - When the panel renews a certificate, the change in
acme.jsonre-renders the proxies within the hour, long before the old copy expires (renewal starts 30 days ahead). - The panel only has certificates for hosts it serves itself, or the DNS-01 wildcard of a configured wildcard domain. Every other host on a node keeps its own ACME.
- The trade-off: sharing copies those certificates' private keys to the nodes that route the hosts. It is off by default.
- No migration is needed: the switch is a settings row.
Expiry alerts start firing after the 0.14 upgrade. Before 0.14 the panel could not read the expiry dates in
acme.json(Traefik stores the certificates base64-encoded), so every ACME certificate's expiry was unknown and thecert-expiryalert never fired. If an alert fires right after the upgrade, that certificate really is close to expiry. Check why Traefik is not renewing it (port 80 reachability, DNS, rate limits).
🗄️ 9. Public database access
Make one managed database reachable from outside the host, for a BI tool, a laptop or another cloud: Database → Settings → Public access, ninedeploy databases public-access <id> …, or:
| Route | Who | Purpose |
|---|---|---|
GET /v1/databases/:id/public-access | admin on the database | {supported, configured, enabled, port, tlsMode, tlsHostname, ipAllowlist, status: off|running|error, lastError, appliedAt, publicHost} |
PUT /v1/databases/:id/public-access | Instance operator | {enabled: true, port, ipAllowlist, tlsMode: none|terminate, tlsHostname?}; applied before the answer |
DELETE /v1/databases/:id/public-access | Instance operator | Turn it off; the settings are kept for a later re-enable |
Turning it on spends a host-wide port and puts the database within reach of the internet, so it is operator-only, the same precedent as Database Studio.
⚠ Public access exposes the database's root (superuser) account. The connection string NineDeploy gives you, including
publicConnectionStringinGET /v1/databases/:id/credentials, uses the account the panel created the database with. Before you share an endpoint, create a separate user inside the database with only the rights the client needs, and give out that user instead.
How it works. Each database with public access gets its own small Traefik container, nd-dbpub-<slug>. The panel's main Traefik is never touched, so changing a database's access can never take the HTTP ingress down. The sidecar:
- publishes exactly one host port (
-p <port>:7000) and joins theninedeploynetwork. A TCP router (HostSNI(*)) behind anipAllowListmiddleware forwards tond-db-<slug>on the engine's port; - runs with
--cap-drop ALL,no-new-privileges, 128 MB of memory and half a CPU, as the panel's own uid:gid, with its config (<data>/dbproxy/<slug>/, mode 0600) mounted read-only; - carries the labels
ninedeploy.public-db=<databaseId>and a config fingerprint.
Engines. postgres, mysql, mariadb, redis, valkey, keydb, dragonfly and mongo. clickhouse and meilisearch speak HTTP: put a service with a domain in front of them instead. rabbitmq is not supported yet. Both are refused with 422.
The allow-list is required.
- 1–100 entries, each an IPv4 or IPv6 address or CIDR range. An empty list is never "allow everyone".
- A
/0range (0.0.0.0/0,::/0) is refused, and so are IPv4-mapped IPv6 entries (write the IPv4 form). Entries are stored normalised, with the host bits cleared. - Prefer single addresses or narrow ranges. The UI warns about ranges wider than /16 (IPv4) or /48 (IPv6), and about private, loopback and link-local ranges: Docker's userland proxy can rewrite the client address to the bridge gateway, so a private range can admit more than you expect.
- IPv6 clients are reached only when Docker's IPv6 support is on and the list holds IPv6 entries.
Port. 1024–65535. Not a port NineDeploy listens on (panel, Traefik, SSH), not another database's public port, and not a service's published port (409). A port another host process already holds fails when the sidecar starts, and the API answers 409 with Docker's message.
TLS.
none(the default): plain TCP passthrough. Postgres, MySQL and MariaDB still negotiate their own TLS end to end if the server and client are set up for it.terminate: the sidecar terminates TLS with an uploaded certificate coveringtlsHostname(section 8), or with Traefik's default self-signed certificate when none covers it. With the default certificate,sslmode=requireworks andverify-fulldoes not. Allowed for postgres, redis, valkey and mongo; refused for mysql and mariadb, whose TLS is negotiated inside the protocol. For postgres in this modepublicConnectionStringcarries?sslmode=require. Postgres through a terminating proxy relies on Traefik's Postgres STARTTLS support, which has not been verified end to end. If a client cannot connect, switch back tonone.
Where clients connect. publicHost is tlsHostname, else the panel domain, else the host of the panel's public URL. Point a DNS name at the server if you need a stable name.
Lifecycle.
- An allow-list or TLS change on the same port rewrites the sidecar's config, and Traefik reloads it without dropping the port. A port change recreates the sidecar, which drops that database's open public connections.
- If an apply fails, the previous sidecar is restored and the settings stay as they were (audited as
database.public_access.apply_failed). - Stopping or restarting the database needs nothing: the sidecar resolves it when a client connects. Deleting the database removes its sidecar first.
- At boot and every 5 minutes, the panel makes every enabled database's sidecar run with its current config, and removes orphan
ninedeploy.public-dbcontainers whose config lives under this panel's<data>/dbproxy. - Uploading, replacing or deleting a certificate re-renders the config of every sidecar in
terminatemode. - Changes are audited as
database.public_access.enable,.updateand.disable, with the port, the number of allow-list entries and the TLS mode, never the addresses.
Rolling back to 0.13 leaves the sidecars running with their allow-lists, and 0.13 cannot turn them off. Remove them with docker rm -f $(docker ps -aq --filter label=ninedeploy.public-db). See ROLLBACK.md.
📈 10. Traffic analytics (0.15, opt-in)
Requests, status codes and latency per domain, read from Traefik's access log: Traefik → Traffic (operators), the traffic card on a service's page, ninedeploy traffic …, or the API:
| Route | Who | Purpose |
|---|---|---|
GET /v1/traffic/settings | Instance operator | {enabled, retentionDays, status: off|starting|running|error, lastError, lastIngestAt, logBytes, malformedLines, dockerLogDriver} |
PUT /v1/traffic/settings | Instance operator | {enabled?, retentionDays?}; answers with the GET shape |
GET /v1/traffic/summary?range=1h|24h|7d|30d&top=10 | Instance operator | Instance totals, a series, the top domains, the panel and the custom-config buckets, p50/p95/p99 |
GET /v1/services/:id/traffic?range=… | Any seat on the service (read/services) | The same for the service's domains; empty series, never 404, without data |
1h and 24h use minute buckets, 7d and 30d hour buckets; every answer states its granularity and whether analytics is enabled. Percentiles are estimated from a 12-bucket latency histogram (edges 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000 and 10000 ms). The read-only MCP tools are traffic_summary (per service) and instance_traffic_summary (operator).
It is off on every install, new or upgraded. With it off, the static config still says accessLog: {}, byte for byte what 0.14 wrote, so upgrading never recreates ninedeploy-traefik. Turning it on or off recreates Traefik once, synchronously, through the usual guarded path: about 1–2 seconds of refused connections. If the recreate fails, the setting goes back to its previous value, the previous config is re-applied and the answer is 502 traefik_recreate_failed. A browser that reaches the panel through Traefik can lose the answer to the recreate itself; the web card reads the settings again.
What is logged. When on, accessLog: {} is replaced by a JSON access log in a file:
accessLog:
filePath: /var/log/ninedeploy-traffic/access.log
format: json
fields:
defaultMode: drop
names:
StartUTC: keep
RouterName: keep
ServiceName: keep
RequestHost: keep
RequestMethod: keep
DownstreamStatus: keep
DownstreamContentSize: keep
Duration: keep
OriginDuration: keep
headers:
defaultMode: dropEvery field not listed is dropped, and every header. No client IP, no path, no query string, no user name and no header ever reaches the disk. The host name is kept so the history keeps a label after a domain is deleted. Turning analytics on also ends the stdout access log, which held full request lines with query strings (OAuth codes, tokens in links) for as long as Docker kept the container log.
Where the log lives. <data>/traffic-logs/, mounted read-write into Traefik at /var/log/ninedeploy-traffic only while analytics is on. The panel creates the directory, so it can rename and delete the files Traefik writes. It sits outside <data>/traefik/, so the system export never includes it.
How it is read. The panel reads new complete lines every 10 seconds (at most 32 MiB per pass) from a cursor it stores with the counts in the same transaction, so a crash neither loses nor double-counts lines. Lines are attributed by router name: <slug>_<domainId> (and its _http twin) to the domain and its service, ninedeploy_panel* to the panel, custom-*/custom_* to your custom config, anything else to other. Malformed lines are skipped and counted in malformedLines.
Rotation and disk use. Once the file has been read past 64 MiB, the panel renames it to access.log.1 and sends Traefik SIGUSR1, which reopens the log; the old file is drained and deleted on a later pass. That keeps the directory near 2 × 64 MiB while the panel runs. If Traefik does not reopen the file, the panel falls back to truncating after each read, losing at most one pass of lines. While the panel is down Traefik keeps appending; if the file is over 1 GiB at boot, the panel skips to its end, rotates, and audits traffic.log_skipped with the number of bytes skipped.
Turning it off recreates Traefik without the mount and with accessLog: {} again, drains what is left, and deletes the files in <data>/traffic-logs. The counts stay until retention.
Retention. Minute rows are kept 48 hours; hour rows retentionDays (default 30, 1–400). The hourly housekeeping deletes them in batches.
Not covered in 0.15: node proxies (their traffic is not counted), paths, client addresses and user agents (by design), and alerts on error rates or latency.
Changes are audited as traffic.settings.update, plus traffic.enable / traffic.disable with the previous state.
Log rotation for Traefik's own container log (0.15)
Through 0.14, Traefik's stdout, where the default access log goes, was written to Docker's json-file log with no size limit, on the panel host and on every node. From 0.15, when docker info reports the json-file or local log driver, ninedeploy-traefik and node proxies are started with --log-opt max-size=20m --log-opt max-file=3. With any other driver nothing is added, because an option the driver does not accept would make docker run fail and take the ingress down.
The option is not part of the config fingerprint, so it never forces a recreate: it applies the next time the proxy is recreated for another reason (an ACME or DNS change, a Traefik update, turning analytics on or off). GET /v1/traffic/settings shows the detected driver as dockerLogDriver. To apply it sooner on the panel host, turn analytics on and off again; on a node, it applies at the node proxy's next recreate, with a 0.15 agent.
Rolling back to 0.14 with analytics on: 0.14 renders accessLog: {}, sees the fingerprint change and recreates Traefik once without the mount. <data>/traffic-logs stays on disk; see ROLLBACK.md.
Source guide (installer links and live inventory counts are normalized for this site): docs/TRAEFIK_INGRESS.md.