
# Exposing the instance to the Internet without surprises

Before opening the instance to the public, go through the short list, start the production stack and set up your reverse proxy: these three steps cover what the application cannot do for you. For an overview of what is expected of a host, see [host Planning Équipes yourself](/heberger/).

## Before opening: the short list

- [ ] `ADMIN_PASSWORD` long, generated, specific to this deployment: the application **refuses to start** in production if it is still the example, `DB_PASSWORD` included;
- [ ] `DB_PASSWORD` changed;
- [ ] `SESSION_ENCRYPTION_KEY` set (≥ 16 characters) and kept;
- [ ] `PUBLIC_URL` in `https://`;
- [ ] `PLANNING_MCP_API_KEY` empty while the MCP server serves nobody (empty, `/mcp` answers `401` to everything; set, it calls for `CONNEXION_PROXYS_FIABLES` with it: [MCP server rate](securite-limites-de-debit.md#débit-du-serveur-mcp));
- [ ] `CONNEXION_PROXYS_FIABLES` set before creating a wall-display link, behind a proxy ([the sign-in lockout](securite-acces-administration.md#verrouiller-le-formulaire-de-connexion-de-ladmin));
- [ ] behind an OIDC provider: a named administrator account created and tried **before** leaving the fallback closed, `ADMIN_LOCAL_SECOURS` absent or `false` in normal operation, `OIDC_CLIENT_SECRET` at least 32 characters;
- [ ] no `REMOTE_USER_*` variable: the proxy-header mode is removed in 4.0, and since 5.0 startup ignores them without flagging them any more;
- [ ] `LEGAL_MENTIONS` set: `/mentions-legales` is public, and an empty page counts as no notices. Five keys (publisher, host, contact, legal basis, retention) **make a public instance (`PUBLIC_INSTANCE=true`) fail to start** and only warn otherwise ([legal notices](mentions-legales.md));
- [ ] production data loaded, never the test fixtures.

## Starting the production stack

`docker-compose.yml` is a **development** stack: it publishes PostgreSQL on the host, adds pgAdmin as `admin/admin`, an SMTP sink that sends nothing and `festival`/`admin` passwords. "We'll change the passwords" removes neither pgAdmin nor port 5432. `docker-compose.prod.yml` is the matching stack:

```bash
docker compose -f docker-compose.prod.yml --env-file .env.prod up -d
```

- **a named version**: `APP_VERSION` is mandatory (a `vX.Y.Z`, never `:main` or `:latest`, see [`versioning.md`](versioning.md));
- **a single published port**, on the loopback (`127.0.0.1:8080`): the reverse proxy is the only way in; PostgreSQL is not published at all; no pgAdmin or Mailpit;
- **no default value on secrets**: `DB_PASSWORD`, `ADMIN_PASSWORD`, `SESSION_ENCRYPTION_KEY`, `PUBLIC_URL`, `MAIL_HOST` and `MAIL_FROM` make startup fail if missing;
- **a backup directory** on the host (`./backup`) mounted on `BACKUP_DIR`, where the night task writes its `pg_dump`, the only place the application writes to disk. These files are the full dataset in clear, minors included: restricted access on the host, an encrypted off-machine copy, never in a ticket or on a demo instance, and never served by the reverse proxy (the application exposes them through no endpoint);
- **two public probes**, `/q/health/live` and `/q/health/ready`, with no session (a probe cannot authenticate): they return only `UP`/`DOWN`, the names of their checks and two migration counters. Quarkus's data-source check is off: on failure it copied the driver message, hence the database host and port ([`exploitation.md`](exploitation.md));
- **port 9000 is not published**: the management interface serves the Prometheus metrics (`/q/metrics`) **without authentication**, its only protection is being reachable from the internal network alone. The image does not declare it in `EXPOSE`, so a `docker run -P` does not publish it. The application port does not serve the metrics (`404`) and no label carries a token, address or id ([`observabilite.md`](observabilite.md)).

## What is left to the reverse proxy

The application cannot do these itself, and they are **prerequisites** of the above:

| To do | Why |
| --- | --- |
| Terminate TLS and redirect all http to https | HSTS and the `Secure` flag of the space cookie only activate on an HTTPS visit |
| Forward the visitor's `Host` and `X-Forwarded-Proto` | The application compares a request's origin to this scheme and host: without them, the administration sees each of its writes refused with 403 ([a single origin](securite-navigateur.md#une-seule-origine)) |
| **Set `CONNEXION_PROXYS_FIABLES`** to your proxies (addresses or CIDR blocks) | Without it, the per-address caps ignore `X-Forwarded-For` and count all visitors on one counter: safe, but the first attacker locks everybody out. **Mandatory as soon as `/mcp` serves** (that cap counts every request) **and as soon as a wall-display link exists**: a few random requests would lock the proxy's address, and a screen plugged in or restarted would show nothing until the lock ends. `QUARKUS_HTTP_PROXY_TRUSTED_PROXIES` does not replace it: it decides whether the header is read, never which element is kept |
| **Make the origin unreachable other than through the proxy** (firewall, network) | Otherwise `X-Forwarded-Proto` stays forgeable, and an attacker reaching the origin is counted on their real address but without the benefit of the list above |
| Rate-limit per IP address on the whole site | The application's caps are targeted (admin sign-in, space codes, MCP, wall display); exports and API have none. Solving has an optional [instance quota](securite-limites-de-debit.md#quota-de-calcul), which a per-address limit does not replace |
| **Let `X-Api-Key` through on `/api`, or strip it** | [Named API keys](../comprendre/mcp-connexion.md#une-clé-nommée-limitée-à-un-rôle-et-à-des-éditions) open `/api` with no session and no second factor, like `/mcp`: a proxy rule demanding a human session in front of `/api` stops a script too. Open calls carrying `X-Api-Key` by a rule on the header or the path and let the key stand guard — and if you set `PLANNING_MCP_REQUIRED_HEADERS`, the requirement applies to a named key on `/api` too: without those headers the key is refused like an unknown one, and the origin stays closed to anyone reaching it without going through the proxy; if no script needs one, create no key and strip the header at the proxy. The more keys, the wider the surface exposed behind the proxy: one per use, editions named, an expiry set |
| Log without the staff-space, **ICS-subscription or wall-display** URLs, or purge those logs | The three tokens travel **in the path**; the subscription returns at every calendar sync, the wall display every minute |
| Never route or publish port 9000 | No authentication: protected by the network, not a password. A scraper outside the stack goes through a tunnel or private network |
| Restrict `/q/health/*` to the monitoring source, if known | Nothing sensitive is read there, but a probe need not be reachable from the whole world; the compose `healthcheck` goes through the loopback |
| Do not put the site back into an index (proxy home page, sitemap, internal directory) | The application says [three times](securite-navigateur.md#ne-pas-être-référencé-dit-trois-fois) that it does not want to be indexed; a link from a public page gets noticed |

## HTTP server caps

| Variable | Default | What it bounds |
| --- | --- | --- |
| `MAX_BODY_SIZE` | `10M` | Maximum size of a request body. The largest body expected is a YAML scenario: a deployment does well to lower it sharply |
| `MAX_CONNECTIONS` | `500` | Simultaneous connections; this cap stops the server being exhausted by silent connections |
| `HTTP_IDLE_TIMEOUT` | `PT16M` | Time after which a silent connection is closed and frees its place |

Quarkus's delay (30 min) is brought down to 16 min, just above the longest synchronous call: a solve launched by `POST /api/solve`, which writes nothing before its end (900 s by default). Whoever allows longer synchronous solves raises `HTTP_IDLE_TIMEOUT` by as much; the reverse proxy remains the right place to cut idle clients earlier.

Two imports have bounds written in the code:

- **staff CSV**: 1,000,000 characters and 5,000 data rows, read in memory in one piece and never written to disk ([`rgpd.md`](rgpd.md));
- **YAML scenario**: it bounds what the file represents, not only what it weighs. An alias (`*nom`) repeats a list without copying it: a few hundred bytes of nested aliases can stand for billions of elements. A file exceeding 2,000,000 elements once its aliases are resolved, or whose alias contains itself, is refused before being read further (the largest shipped scenario has about 85,000).

These caps do not replace the reverse proxy's, the first line (rate per IP, connections per client, timeouts). The application **compresses** its JSON responses and the interface files (gzip) for any client announcing it, never the solve progress stream, which must leave event by event.

## The server's clock, for the second factor

An authenticator app's code is computed from the time: **the server needs a correct clock**, synchronised by NTP (`timedatectl status` must show `System clock synchronized: yes`, with `systemd-timesyncd` or `chrony` running on the host; a container reads its host's clock). The application accepts a drift of one 30-second step either way; beyond that every code is refused, and the failure looks like a wrong code. An account that no longer gets in: check the server's time first, then the phone's. The secret is encrypted with `INSTANCE_SECRET_KEY` (the webhook secrets' key): without it nobody can turn the second factor on, and changing it makes the secrets already stored unreadable. The accounts concerned then have their second factor reset by another administrator ([local accounts](comptes-locaux.md#le-second-facteur-par-application)). At startup **the application refuses to start** as soon as a second factor exists and `INSTANCE_SECRET_KEY` is missing or does not open its secret: put the original key back or, if it is lost, delete the rows of the `compte_totp` and `compte_totp_secours` tables (each account will have to turn its second factor on again).

## Going further

| To… | Read |
| --- | --- |
| Set `CSP` and `HSTS`, understand a browser block | [Setting the browser security headers and the CSP](securite-navigateur.md) |
| Limit abuse (codes, declarations, MCP, solve quota) | [Limiting abuse: rate, lockouts and solve quota](securite-limites-de-debit.md) |
| Choose the administration door and keep the fallback closed | [Choose and protect the admin login](securite-acces-administration.md) |
| Connect your company directory | [Connect your corporate directory (OIDC)](oidc.md) |
| Know what each role opens | [Knowing what each role can call](securite-roles-et-droits.md) |
| Publish a calendar or a wall screen with no session | [Opening a calendar or a screen without opening the administration](securite-jetons-publics.md) |
| Control webhooks, weather and remote solve | [Control what leaves the instance](securite-appels-sortants.md) |
| Know what the release chain checks | [The security checks that run on every version](securite-analyses-automatiques.md) |
| Authentication and tokens on the API and MCP side | [`api-conventions.md`](../comprendre/api-conventions.md), [`mcp-connexion.md`](../comprendre/mcp-connexion.md) |
