Commit 348c8ce
committed
28336e0 refactor: [#272] Set X-Forwarded-For header only for HTTP trackers (Jose Celano)
e464aca feat: [#272] Explicitly set X-Forwarded-For header in Caddy reverse proxy (Jose Celano)
8b6e361 docs: [#272] Add ADRs for HTTPS implementation decisions (Phase 9) (Jose Celano)
6948342 docs: [#272] Explain why test command cannot work in Docker-based E2E tests (Jose Celano)
310f93f docs: [#272] Add revised Phase 6 implementation plan for HTTPS E2E testing (Jose Celano)
bf5df90 docs: [#272] Add HTTPS user documentation (Jose Celano)
2426650 refactor: [#272] Refactor ServiceEndpoint to store validated URL and server IP (Jose Celano)
3815f55 feat: [#272] Add HTTPS support to test command with ServiceEndpoint type (Jose Celano)
c7e0dc4 refactor: [#272] Remove unused TlsSection and domain::tls module (Jose Celano)
01da06e refactor: [#272] Replace tls with domain+use_tls_proxy for Grafana (Jose Celano)
55dfa94 refactor: [#272] Replace tls with domain+use_tls_proxy for Health Check API (Jose Celano)
3662aff refactor: [#272] Replace tls with domain+use_tls_proxy for HTTP API (Jose Celano)
80b4b32 refactor: [#272] replace TlsSection with domain + use_tls_proxy for HTTP trackers (Jose Celano)
d796db7 docs: [#272] Add reproduction steps for on_reverse_proxy issue (Jose Celano)
bf73227 docs: [#272] Document tracker on_reverse_proxy global setting limitation (Jose Celano)
a857e07 docs: [#272] Add subtask 7.5 for use_tls_proxy configuration refactor (Jose Celano)
5334429 feat: [#272] Handle localhost-bound services in show command and validation (Task 7.4) (Jose Celano)
d21f313 docs: [#272] clarify task 7.4 implementation notes (Jose Celano)
f143303 feat: [#272] add HTTPS/TLS support for health check API (Jose Celano)
1855058 docs: [#272] add tasks 7.3 and 7.4 for health check TLS and localhost handling (Jose Celano)
c1c194a feat: [#272] update show command to display HTTPS-enabled services (Jose Celano)
704f153 feat: [#272] add Caddy to Docker security scan workflow (Jose Celano)
c8236eb chore: [#272] add rustc-ice files to gitignore (Jose Celano)
011cd8c refactor: [#272] improve docker-compose template whitespace handling (Jose Celano)
56ad1dc refactor: [#272] add MysqlServiceConfig for MySQL service network configuration (Jose Celano)
d508cc7 refactor: [#272] separate Caddy contexts for Caddyfile and docker-compose templates (Jose Celano)
526e7ab refactor: [#272] rename ports module to tracker for service consistency (Jose Celano)
02a83be refactor: [#272] move Prometheus and Grafana networks logic from Tera to Rust (Jose Celano)
a93596c docs: [#272] add CLI command HTTPS compatibility phase and fix VM file locations (Jose Celano)
1b69af4 refactor: [#272] move tracker networks logic from template to Rust (Jose Celano)
180f364 refactor: [#272] use YAML anchors in docker-compose template for DRY config (Jose Celano)
ef906fc refactor: [#272] simplify docker-compose template by pre-computing TLS flags in Rust (Jose Celano)
7882917 feat: [#272] add HTTPS support with Caddy for all HTTP services (Jose Celano)
3bbaea1 feat: [#272] add Caddy template rendering infrastructure (Jose Celano)
df19401 feat: [#272] add Caddy templates for HTTPS support (Jose Celano)
900aeac docs: [#272] clarify context data preparation pattern for Tera templates (Jose Celano)
Pull request description:
## Summary
Add HTTPS support with Caddy reverse proxy for automatic TLS termination on all HTTP services (Tracker API, HTTP Trackers, Grafana, Health Check API).
Closes #272
## What's Implemented
### Phase 1: Template Creation ✅
- Created `templates/caddy/Caddyfile.tera` with conditional service blocks
- Created `docs/contributing/templates/caddy.md` documenting template variables
- Updated `templates/docker-compose/docker-compose.yml.tera` with Caddy service block
- Registered templates in `CaddyProjectGenerator` with 14 unit tests
### Phase 2: Configuration DTOs ✅
- Added `HttpsSection` DTO with `admin_email` and `use_staging` fields
- Added per-service `domain` and `use_tls_proxy` fields (replaced nested `tls` section)
- Extended `HttpApiSection`, `HttpTrackerSection`, `GrafanaSection`, `HealthCheckApiSection` with TLS options
- Implemented validation (`has_any_tls_configured`, https/tls consistency, uniform HTTP tracker TLS)
- Added `Email` type in `src/shared/email.rs` for email format validation
- Added `DomainName` type in `src/shared/domain_name.rs` for domain validation
### Phase 3: Template Rendering Integration ✅
- Created `RenderCaddyTemplatesStep` for template rendering
- Created `DeployCaddyConfigStep` for Ansible deployment
- Created `deploy-caddy-config.yml` Ansible playbook
- Added `RenderCaddyTemplates` and `DeployCaddyConfigToRemote` to `ReleaseStep` enum
- Integrated `CaddyContext` into Docker Compose template rendering
- Added `CaddyConfigDeployment` error variant with actionable help text
### Phase 4: Security Workflow Updates ✅
- Added `caddy:2.10` to Docker security scan workflow matrix
- Added SARIF upload step for Caddy scan results
- Updated security scan documentation
### Phase 5: Documentation ✅
- Created `docs/user-guide/services/https.md` with complete HTTPS setup guide
- Updated `docs/user-guide/services/README.md` with HTTPS service entry
- Updated `docs/user-guide/services/grafana.md` with TLS proxy fields documentation
- Regenerated JSON schema (`schemas/environment-config.json`)
### Phase 6: E2E Testing ✅ (Manual)
Manual E2E testing verified:
- ✅ HTTPS endpoints working for API, Grafana, and HTTP trackers
- ✅ HTTP→HTTPS redirect (308 Permanent Redirect)
- ✅ HTTP/2 and HTTP/3 enabled
- ✅ Caddy Local CA for `.local` domains
- ✅ X-Forwarded-For header explicitly set for HTTP trackers
- ✅ Announce request through Caddy returns valid bencode response
### Phase 7: Schema Generation ✅
- Regenerated JSON schema with HTTPS configuration
- Schema includes `https`, `domain`, `use_tls_proxy` fields
### Phase 8: ADRs (Decision Documentation) ✅
Three ADRs created:
1. **Caddy for TLS Termination** (`docs/decisions/caddy-for-tls-termination.md`) - Why Caddy was chosen over Pingoo/nginx
2. **Per-Service TLS Configuration** (`docs/decisions/per-service-tls-configuration.md`) - Why `domain + use_tls_proxy` pattern was chosen, including naming rationale
3. **Uniform HTTP Tracker TLS Requirement** (`docs/decisions/uniform-http-tracker-tls-requirement.md`) - Why all HTTP trackers must use same TLS setting
## What's Remaining
- [ ] **Phase 6**: Automated E2E tests (currently only manual testing)
## Configuration Example
```json
{
"https": {
"admin_email": "admin@example.com",
"use_staging": true
},
"tracker": {
"http_api": {
"bind_address": "0.0.0.0:1212",
"admin_token": "secret",
"domain": "api.tracker.local",
"use_tls_proxy": true
},
"http_trackers": [
{
"bind_address": "0.0.0.0:7070",
"domain": "http1.tracker.local",
"use_tls_proxy": true
}
]
},
"grafana": {
"admin_user": "admin",
"admin_password": "admin",
"domain": "grafana.tracker.local",
"use_tls_proxy": true
}
}
```
## Testing
- All pre-commit checks pass
- Manual E2E test results documented in [docs/issues/272-add-https-support-with-caddy.md](docs/issues/272-add-https-support-with-caddy.md)
- X-Forwarded-For header verified on deployed environment
## Key Design Decisions
1. **X-Forwarded-For only for HTTP trackers**: The explicit `header_up X-Forwarded-For {remote_host}` is only set for HTTP trackers (not API, health check, or Grafana) because it's critical only for peer IP tracking in BitTorrent swarms.
2. **`use_tls_proxy` naming**: Named to avoid confusion with tracker's native TLS support (`TslConfig`), reserving namespace for future `use_native_tls` option.
## Notes for Reviewers
Key files to review:
- `templates/caddy/Caddyfile.tera` - Caddy template with explicit X-Forwarded-For for HTTP trackers
- `src/application/command_handlers/create/config/https.rs` - HTTPS configuration DTOs
- `src/application/command_handlers/release/handler.rs` - Release workflow integration
- `src/infrastructure/templating/caddy/` - Caddy template rendering
- `docs/decisions/` - Three new ADRs documenting architectural decisions
ACKs for top commit:
josecelano:
ACK 28336e0
Tree-SHA512: f3ef875536b9b8841bc6e9e21b93cfc161c32e09ad90b073cad022da7b9e50c9ec2dbed46d6f1cde1448cfb04d652a75fe5b536278b8860fe0e10b42cbdab840
File tree
106 files changed
+10713
-941
lines changed- .github/workflows
- docs
- contributing/templates
- decisions
- external-issues/tracker
- issues
- security/docker/scans
- user-guide
- services
- schemas
- src
- application
- command_handlers
- create
- config
- tracker
- tests
- release
- show
- info
- test
- steps
- application
- rendering
- bin
- domain
- environment
- state
- grafana
- https
- tracker
- config
- infrastructure
- external_validators
- templating
- ansible/template
- renderer
- wrappers/variables
- caddy
- template
- renderer
- wrapper
- caddyfile
- docker_compose/template
- renderer
- wrappers/docker_compose
- context
- prometheus/template/renderer
- tracker/template
- renderer
- wrapper/tracker_config
- presentation/views/commands/show/environment_info
- testing/e2e/tasks
- templates
- ansible
- caddy
- docker-compose
- tracker
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
106 files changed
+10713
-941
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
| |||
219 | 220 | | |
220 | 221 | | |
221 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| 68 | + | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
Lines changed: 172 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
248 | 420 | | |
249 | 421 | | |
250 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
| |||
0 commit comments