Skip to content

Commit 1a083e3

Browse files
committed
reject invalid ACME_ENV values and document staging/account behavior
1 parent 8c2159d commit 1a083e3

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,19 @@ A couple of sharp edges:
111111
- The proxy boots even when cert files are missing. It logs a warning and serves what it can.
112112
- The cert is picked by SNI. The TLS handshake only succeeds when the client sends SNI and a cert for that host exists.
113113
- The first ACME cert takes a few minutes. Boot tick writes the TXT record, then a tick every 2 minutes finalizes once the record resolves. Until it lands the host is unreachable: HTTP still 301s to HTTPS, and HTTPS has nothing to serve yet.
114-
- It always talks to Let's Encrypt production, no staging, and agrees to their terms for you. Mind the rate limits while testing.
114+
- It talks to Let's Encrypt production by default and agrees to their terms for you. Set `ACME_ENV=staging` while testing to stay clear of the production rate limits.
115+
- The ACME account is tied to the environment it was created in. Once `acme_account` exists, `ACME_ENV` is ignored. Delete `acme_account` to switch between staging and production.
115116
- No `X-Forwarded-For` / `X-Forwarded-Proto` headers are added. The upstream sees the proxy as the client.
116117

117118
## Environment variables
118119

119-
| Variable | Binary default | In the image | What it does |
120+
| Variable | Binary default | In the image | Notes |
120121
| ------------- | -------------- | ------------------------ | ------------------------------------------------------------ |
121-
| `CONFIG_PATH` | _none, exits_ | `/etc/proxy/config.toml` | Path to the TOML config. Binary exits without one. |
122+
| `CONFIG_PATH` | _none, exits_ | `/etc/proxy/config.toml` | Path to the TOML config. |
122123
| `CERT_DIR` | `.certs/` | `/var/lib/proxy/certs` | Where certs and the ACME account file (`acme_account`) live. |
123124
| `HTTP_PORT` | `80` | `8080` | Port for the HTTP listener. |
124125
| `HTTPS_PORT` | `443` | `8443` | Port for the HTTPS listener. |
126+
| `ACME_ENV` | `production` | `production` | `production` or `staging`. Other values get rejected |
125127

126128
The image bakes in the right-hand column (Dockerfile sets all four), so the compose file above doesn't repeat them. Listeners always bind `0.0.0.0`.
127129

‎src/config.rs‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ impl Config {
4747
.unwrap_or(HTTPS_PORT_DEFAULT);
4848

4949
let acme_env = load_env(ACME_ENV).unwrap_or_else(|_| ACME_ENV_DEFAULT.to_string());
50+
// a typo would silently fall back to staging and issue untrusted certs
51+
if acme_env != "production" && acme_env != "staging" {
52+
return Err(Error::Config(format!(
53+
"{} must be \"production\" or \"staging\", got \"{}\"",
54+
ACME_ENV, acme_env
55+
)));
56+
}
5057

5158
Ok(Config {
5259
email: config_file.acme.email.clone(),

0 commit comments

Comments
 (0)