You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Torrust Tracker has a configuration option `[core.net].on_reverse_proxy` that tells the tracker whether it's running behind a reverse proxy. When `true`, the tracker expects the `X-Forwarded-For` HTTP header to get the real client IP instead of the proxy's IP. This is critical for HTTP trackers to correctly identify peers.
1159
+
1160
+
Currently, in `templates/tracker/tracker.toml.tera`, this option is **hardcoded to `true`**:
1161
+
1162
+
```toml
1163
+
[core.net]
1164
+
on_reverse_proxy = true
1165
+
```
1166
+
1167
+
This is wrong because:
1168
+
1169
+
1. When an HTTP tracker is exposed directly (no Caddy proxy), the tracker expects `X-Forwarded-For` headers that won't exist, causing incorrect peer identification
1170
+
2. The current implementation assumes all HTTP trackers with TLS go through Caddy, but users might want to use the tracker's built-in TLS support without a proxy
1171
+
1172
+
**Tracker Configuration Limitation**:
1173
+
1174
+
The `on_reverse_proxy` option is **global** (in `[core.net]`), not per-tracker. This means:
1175
+
1176
+
- ALL HTTP trackers share the same setting
1177
+
- You cannot have some trackers behind a proxy and others direct in the same deployment
1178
+
- If ANY tracker uses a proxy, ALL trackers must be configured for proxy mode
1179
+
1180
+
This is a limitation in the Torrust Tracker itself (not the deployer). A proper fix would require the tracker to support per-tracker `on_reverse_proxy` settings.
1181
+
1182
+
**Solution**:
1183
+
1184
+
Rename `tls` to a clearer structure with `domain` at the top level and `use_tls_proxy` as a separate boolean. The `tls` name was misleading because it doesn't map to the tracker's TLS config - the domain is only used for Caddy proxy configuration.
The name `use_tls_proxy` accurately describes what our Caddy proxy does: **TLS termination**. This naming choice is intentional for future compatibility:
1345
+
1346
+
1. **Current state**: The tracker has a global `[core.net].on_reverse_proxy` option
1347
+
2. **Future state**: The tracker may add per-tracker `on_reverse_proxy` support
1348
+
3. **No conflict**: When that happens, we can expose both options without ambiguity:
1349
+
1350
+
```json
1351
+
{
1352
+
"bind_address": "0.0.0.0:7071",
1353
+
"domain": "http2.tracker.local",
1354
+
"use_tls_proxy": true,
1355
+
"on_reverse_proxy": true
1356
+
}
1357
+
```
1358
+
1359
+
**Dependency Rule**: `use_tls_proxy: true` → tracker's `on_reverse_proxy` MUST be `true`. This is enforced automatically:
1360
+
1361
+
- When `use_tls_proxy: true`, the deployer sets the tracker's `[core.net].on_reverse_proxy = true`
1362
+
- This is because Caddy sends `X-Forwarded-For` headers that the tracker must read
1363
+
1364
+
**Future Compatibility**: If the tracker adds per-tracker `on_reverse_proxy`:
1365
+
1366
+
- `use_tls_proxy` controls Caddy inclusion and implies `on_reverse_proxy: true`
1367
+
- `on_reverse_proxy`could be explicitly set for edge cases (non-TLS reverse proxy)
- Set to `true` if ANY HTTP tracker has `use_tls_proxy: true`
1375
+
- Set to `false` otherwise
1376
+
- Note: This only affects HTTP trackers; other services ignore it
1377
+
1378
+
2. **Caddy config** (Caddyfile):
1379
+
1380
+
- Include service in Caddy config only if `use_tls_proxy: true`
1381
+
- Requires `domain` to be present for the virtual host configuration
1382
+
1383
+
3. **Validation rules**:
1384
+
- `use_tls_proxy: true` requires `domain` to be present
1385
+
- Localhost bind addresses with `use_tls_proxy: true` should be rejected (proxy can't reach localhost)
1386
+
1387
+
**Known Limitation** (due to tracker's global setting):
1388
+
1389
+
If you have multiple HTTP trackers where some use `use_tls_proxy` and others don't, the ones without it will still receive the global `on_reverse_proxy = true` setting and may fail if they receive direct requests without `X-Forwarded-For` headers.
1390
+
1391
+
**Workaround**: Ensure all HTTP trackers in a deployment either ALL use the TLS proxy or NONE use it.
- [ ] Update tracker config template (`templates/tracker/tracker.toml.tera`) to conditionally set `on_reverse_proxy` based on ANY HTTP tracker having `use_tls_proxy: true`
1406
+
- [ ] Update Caddy template (`templates/caddy/Caddyfile.tera`) to check `use_tls_proxy` for HTTP trackers
1407
+
- [ ] Update show command `ServiceInfo` for HTTP trackers
1408
+
- [ ] Update `envs/manual-https-test.json` for HTTP trackers only
1409
+
- [ ] Remove `TlsSection` from HTTP trackers (keep in other services temporarily)
1410
+
- [ ] Add unit tests for HTTP tracker validation
1411
+
- [ ] Run E2E tests to verify HTTP trackers work
1412
+
1413
+
##### Step 7.5.2: Tracker REST API
1414
+
1415
+
- [ ] Add `domain: Option<String>` and `use_tls_proxy: Option<bool>` to `HttpApiSection` DTO
1416
+
- [ ] Update `HttpApiConfig` domain type
1417
+
- [ ] Add validation rules (same as HTTP trackers)
1418
+
- [ ] Update Caddy template for API
1419
+
- [ ] Update show command `ServiceInfo` for API
1420
+
- [ ] Update `envs/manual-https-test.json` for API
1421
+
- [ ] Remove `TlsSection` from API
1422
+
- [ ] Add unit tests for API validation
1423
+
- [ ] Run E2E tests
1424
+
1425
+
##### Step 7.5.3: Tracker Health Check API
1426
+
1427
+
- [ ] Add `domain: Option<String>` and `use_tls_proxy: Option<bool>` to `HealthCheckApiSection` DTO
1428
+
- [ ] Update `HealthCheckApiConfig` domain type
1429
+
- [ ] Add validation rules
1430
+
- [ ] Update Caddy template for health check
1431
+
- [ ] Update show command `ServiceInfo` for health check
1432
+
- [ ] Update `envs/manual-https-test.json` for health check
1433
+
- [ ] Remove `TlsSection` from health check
1434
+
- [ ] Add unit tests
1435
+
- [ ] Run E2E tests
1436
+
1437
+
##### Step 7.5.4: Grafana
1438
+
1439
+
- [ ] Add `domain: Option<String>` and `use_tls_proxy: Option<bool>` to `GrafanaSection` DTO
1440
+
- [ ] Update `GrafanaConfig` domain type
1441
+
- [ ] Add validation rules (note: Grafana has no configurable bind address, so localhost validation not needed)
1442
+
- [ ] Update Caddy template for Grafana
1443
+
- [ ] Update show command `ServiceInfo` for Grafana
1444
+
- [ ] Update `envs/manual-https-test.json` for Grafana
1445
+
- [ ] Remove `TlsSection` from Grafana
1446
+
- [ ] Add unit tests
1447
+
- [ ] Run E2E tests
1448
+
1449
+
##### Step 7.5.5: Cleanup and Final Verification
1450
+
1451
+
- [ ] Remove `TlsSection` type completely (should be unused after all services migrated)
1452
+
- [ ] Run full E2E test suite
1453
+
- [ ] Run all linters
1454
+
- [ ] Manual verification with `envs/manual-https-test.json`
0 commit comments