Domains, TLS and reverse proxies
Serve the app and landing on your domains with Caddy, or behind a proxy you already run.
This page explains how people reach your mlflow server: the host name, the HTTPS certificate, and what to do if another web server already owns ports 80 and 443.
Two hosts
A server made by the installer uses one host name. The web app, the API and the live run updates are all served at https://<your domain>, which you give with --domain. Inside the server, requests take this path:
- Caddy receives HTTPS on ports 80 and 443. It is the only service that publishes ports.
- Caddy forwards everything to the
webservice, an nginx server. - nginx serves the app and sends
/api/requests and the run-events WebSocket to theapiservice. It sends/healthzto the API, too.
You do not need a separate API host.
The full production stack that mlflow itself uses for its public sites can serve three host names from the same Caddy: the app (for example app.example.com), a landing site on the main domain, and a learning site. These are set with three variables, PYCARET_APP_DOMAIN, PYCARET_SITE_DOMAIN and PYCARET_LEARN_DOMAIN. The site and learning hosts are optional: when they are not set, nothing is routed for them and no certificate is requested. Customer installations do not include the landing and learning sites, so for you the answer is one host.
Automatic TLS with Caddy
Caddy gets and renews a free certificate from Let's Encrypt on its own. For this to work:
- The host name must resolve to the server's public address. Create the
Arecord (andAAAAif you use IPv6) before you install. - Ports 80 and 443 must be reachable from the internet, in the server's firewall and in any cloud security group.
- The contact address (
--email, by default the administrator's email) receives expiry notices.
Certificates are kept in a Docker volume, so restarting the server does not request new ones. Do not delete this volume casually: requesting too many certificates for one name makes Let's Encrypt refuse new ones for a while.
--domain value | Certificate |
|---|---|
A public host name, for example mlflow.example.com | A trusted Let's Encrypt certificate. |
localhost or an IP address | A certificate from Caddy's own authority. Browsers show a warning and curl needs -k. |
Use localhost for a trial on your own machine. If your network has its own certificate authority and the server cannot reach Let's Encrypt, put a proxy of your own in front and let it provide a trusted certificate, as described next.
Two settings in /opt/mlflow/.env can move the published ports: MLFLOW_HTTP_PORT and MLFLOW_HTTPS_PORT (defaults 80 and 443). Certificates for a public name need port 80 reachable from the internet, so change them only for a test or a private network.
Behind an existing proxy
If another web server on the machine already uses ports 80 and 443 (Caddy, nginx, Traefik and others), the installer stops with "port 80 is already in use" rather than compete with it. You have two choices. Run mlflow on its own machine, or ask your mlflow contact for the layout that leaves the built-in Caddy out and attaches the application to your proxy's Docker network.
In that layout, your proxy is the only thing that terminates TLS. It must forward the whole host name to one upstream, the web service on port 8080. You do not need to route /api separately: the web service already does that. The proxy has to do three things:
- support WebSocket upgrades, because runs stream events over a long-lived connection;
- allow long requests: uploads and exports can take minutes. Set read timeouts to at least 300 seconds, and to an hour for the
/api/v1/runs/path; - not buffer responses to the live-event routes.
mlflow.example.com {
encode zstd gzip
reverse_proxy pycaret-web:8080 {
flush_interval -1
}
}server {
listen 443 ssl;
server_name mlflow.example.com;
# ssl_certificate and ssl_certificate_key go here
client_max_body_size 200m;
location / {
proxy_pass http://pycaret-web:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
}The name pycaret-web is the alias that the web service has on the proxy's Docker network in that layout. Use the name your contact gives you. client_max_body_size must be at least as large as the biggest file you want people to upload.
Forwarded headers
Several limits depend on the caller's address: the sign-in and sign-up limits, and the limit on public endpoints. Behind a proxy, every request seems to come from the proxy, so the server reads the real address from the X-Forwarded-For header. Two settings control this:
| Setting | Default | Meaning |
|---|---|---|
PYCARET_TRUST_FORWARDED_FOR | false | Trust the X-Forwarded-For header. |
PYCARET_FORWARDED_FOR_HOPS | 1 | How many proxies add an address to the header. The client address is the entry that many places from the right. |
The installer sets them to true and 2: Caddy adds one entry and the web container's nginx adds the second. If you add a proxy of your own in front, the count must match the proxies in the chain. With the built-in Caddy left out, as above, the count is 2 again: your proxy and the web container.
Set the count to the real number of proxies
Turn on trust only when the API can be reached solely through your proxies, which is how the installed stack works. With trust off behind a proxy, every user shares one rate-limit bucket: by default 10 sign-ins per minute and 5 sign-ups per hour for the whole server. With too many hops configured, a caller can forge their own address and escape the limits. Your proxy must also add or overwrite X-Forwarded-For itself, not pass on a value from the client.
Make sure your proxy sets X-Forwarded-Proto and Host, as in the nginx example above.
CORS
Browsers only let a web page call an API on another origin if that API allows it. In the standard setup the app and the API share one host name, so the browser never makes a cross-origin call and nothing more is needed. The installer still sets PYCARET_CORS_ORIGINS to your own address, ["https://<your domain>"], as a JSON list.
The setting matters only if a web page on a different origin must call the API from the browser. In that case, add that origin to the list. Scripts, the MCP server and deployment kits are not browsers, so they are not affected by CORS. They authenticate with an API key.
Two related settings use the public address and must match it:
PYCARET_PUBLIC_BASE_URL, the address placed in the links of emails such as password resets. The installer sets it tohttps://<your domain>.PYCARET_PUBLIC_URL, used to build the monitor URL shown for models deployed elsewhere. If it is unset, the server uses the host of the request.
If you change the domain later, run the installer again with the new --domain: it updates the file and keeps your data. Then check that DNS and the certificate are in place.
Next steps
Updated 2026-11-22