Skip to content

Commit a93596c

Browse files
committed
docs: [#272] add CLI command HTTPS compatibility phase and fix VM file locations
1 parent 1b69af4 commit a93596c

1 file changed

Lines changed: 175 additions & 8 deletions

File tree

docs/issues/272-add-https-support-with-caddy.md

Lines changed: 175 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,23 @@ ssh -i fixtures/testing_rsa -o StrictHostKeyChecking=no torrust@<VM_IP> "docker
872872

873873
**5. Key file locations on the VM**:
874874

875-
| File | Location on VM | Location in Container |
876-
| ------------------ | -------------------------------------- | ----------------------- |
877-
| Caddyfile | N/A (bind mount) | `/etc/caddy/Caddyfile` |
878-
| docker-compose.yml | `/home/torrust/app/docker-compose.yml` | N/A |
879-
| Tracker config | Bind mount from host | `/etc/torrust/tracker/` |
880-
| Caddy certificates | Docker volume `caddy_data` | `/data/` |
875+
| File | Location on VM | Location in Container |
876+
| ------------------ | ------------------------------------------ | ------------------------------------ |
877+
| docker-compose.yml | `/opt/torrust/docker-compose.yml` | N/A |
878+
| .env | `/opt/torrust/.env` | N/A |
879+
| Caddyfile | `/opt/torrust/storage/caddy/etc/Caddyfile` | `/etc/caddy/Caddyfile` (bind mount) |
880+
| Tracker config | `/opt/torrust/storage/tracker/etc/` | `/etc/torrust/tracker/` (bind mount) |
881+
| Caddy certificates | Docker volume `caddy_data` | `/data/` |
882+
883+
**App directory**: The application is deployed to `/opt/torrust/`, **NOT** `/home/torrust/app/`. This is the working directory for docker compose commands on the VM.
884+
885+
```bash
886+
# Example: Check running containers on the VM
887+
ssh -i fixtures/testing_rsa torrust@<VM_IP> "cd /opt/torrust && docker compose ps"
888+
889+
# Example: View docker-compose.yml on the VM
890+
ssh -i fixtures/testing_rsa torrust@<VM_IP> "cat /opt/torrust/docker-compose.yml"
891+
```
881892

882893
**6. Port exposure verification**:
883894

@@ -895,7 +906,149 @@ tracker 6969/udp, 7072/tcp # 7070, 7071 NOT exposed (Caddy handles them)
895906
caddy 80/tcp, 443/tcp, 443/udp # Entry point for HTTPS
896907
```
897908

898-
### Phase 7: Schema Generation (30 minutes)
909+
### Phase 7: CLI Command Compatibility with HTTPS (3-4 hours)
910+
911+
When HTTPS is enabled, the deployer commands must adapt their behavior to work with domain-based URLs instead of direct IP addresses, and handle internal ports that are no longer directly accessible.
912+
913+
#### 7.1: Update `test` command for HTTPS-enabled environments
914+
915+
**Current Problem**: The `test` command validates services by accessing them directly via IP and internal ports (e.g., `http://10.140.190.214:1212/api/health_check`). When TLS is enabled for a service:
916+
917+
1. The internal port (e.g., 1212) is not exposed externally - only Caddy ports (80, 443) are exposed
918+
2. The service should be accessed via its HTTPS domain (e.g., `https://api.tracker.local`)
919+
920+
**Current Behavior** (fails when TLS enabled):
921+
922+
```text
923+
$ cargo run -- test manual-https-test
924+
925+
⏳ [1/3] Validating environment...
926+
⏳ ✓ Environment name validated: manual-https-test (took 0ms)
927+
⏳ [2/3] Creating command handler...
928+
⏳ ✓ Done (took 0ms)
929+
⏳ [3/3] Testing infrastructure...
930+
❌ Test command failed: Validation failed for environment 'manual-https-test': Remote action failed: Action 'running-services-validation' validation failed: Tracker API external health check failed: error sending request for url (http://10.140.190.214:1212/api/health_check). Check that tracker is running and firewall allows port 1212.
931+
```
932+
933+
**Required Changes**:
934+
935+
- [ ] Detect if a service has TLS enabled from environment configuration
936+
- [ ] For TLS-enabled services:
937+
- [ ] Use the configured domain with HTTPS protocol instead of IP with internal port
938+
- [ ] For local/test domains (e.g., `.local`), accept self-signed certificates from Caddy's local CA
939+
- [ ] Show clear message: "Testing via HTTPS endpoint: https://api.tracker.local"
940+
- [ ] For non-TLS services:
941+
- [ ] Continue using direct IP and port access as before
942+
- [ ] Update error messages to clarify the HTTPS testing behavior
943+
944+
**Expected Behavior After Fix**:
945+
946+
```text
947+
Testing Tracker API via HTTPS: https://api.tracker.local/api/health_check ✅
948+
Testing HTTP Tracker (non-TLS): http://10.140.190.214:7072/announce ✅
949+
```
950+
951+
#### 7.2: Update `show` command for HTTPS-enabled environments
952+
953+
**Current Problem**: The `show` command displays service endpoints using only IP addresses and internal ports, which are misleading when HTTPS is enabled:
954+
955+
1. Displayed URLs may not work (internal ports not exposed)
956+
2. Users don't know the correct HTTPS URLs to use
957+
3. No indication that domain-based access is required
958+
959+
**Current Behavior** (shows incorrect URLs when TLS enabled):
960+
961+
```text
962+
$ cargo run -- show manual-https-test
963+
964+
Environment: manual-https-test
965+
State: Running
966+
Provider: LXD
967+
Created: 2026-01-14 11:08:00 UTC
968+
969+
Infrastructure:
970+
Instance IP: 10.140.190.214
971+
SSH Port: 22
972+
SSH User: torrust
973+
SSH Key: /home/.../fixtures/testing_rsa
974+
975+
Connection:
976+
ssh -i /home/.../fixtures/testing_rsa torrust@10.140.190.214
977+
978+
Tracker Services:
979+
UDP Trackers:
980+
- udp://10.140.190.214:6969/announce
981+
HTTP Trackers:
982+
- http://10.140.190.214:7070/announce # ❌ Port not exposed (TLS enabled)
983+
- http://10.140.190.214:7071/announce # ❌ Port not exposed (TLS enabled)
984+
- http://10.140.190.214:7072/announce # ✅ Works (no TLS)
985+
API Endpoint:
986+
- http://10.140.190.214:1212/api # ❌ Port not exposed (TLS enabled)
987+
Health Check:
988+
- http://10.140.190.214:1313/health_check
989+
990+
Prometheus:
991+
Internal only (localhost:9090) - not exposed externally
992+
993+
Grafana:
994+
http://10.140.190.214:3100/ # ❌ Port not exposed (TLS enabled)
995+
996+
Services are running. Use 'test' to verify health.
997+
```
998+
999+
**Required Changes**:
1000+
1001+
- [ ] Detect if a service has TLS enabled from environment configuration
1002+
- [ ] For TLS-enabled services:
1003+
- [ ] Show HTTPS URL with configured domain: `https://api.tracker.local`
1004+
- [ ] Show HTTP redirect URL: `http://api.tracker.local` (redirects to HTTPS)
1005+
- [ ] Add note: "Direct IP access not available when TLS is enabled"
1006+
- [ ] For non-TLS services:
1007+
- [ ] Show direct IP URL as before: `http://10.140.190.214:7072`
1008+
- [ ] Add informational section explaining:
1009+
- [ ] "Services with TLS enabled must be accessed via their configured domain"
1010+
- [ ] "For local domains (\*.local), add entries to /etc/hosts pointing to the VM IP"
1011+
- [ ] "Internal ports are not directly accessible when TLS is enabled"
1012+
1013+
**Expected Output After Fix**:
1014+
1015+
```text
1016+
Environment: manual-https-test
1017+
State: Running
1018+
Provider: LXD
1019+
Created: 2026-01-14 11:08:00 UTC
1020+
1021+
Infrastructure:
1022+
Instance IP: 10.140.190.214
1023+
SSH Port: 22
1024+
SSH User: torrust
1025+
1026+
Tracker Services:
1027+
UDP Trackers:
1028+
- udp://10.140.190.214:6969/announce
1029+
HTTP Trackers (HTTPS via Caddy):
1030+
- https://http1.tracker.local/announce
1031+
- https://http2.tracker.local/announce
1032+
HTTP Trackers (direct):
1033+
- http://10.140.190.214:7072/announce
1034+
API Endpoint (HTTPS via Caddy):
1035+
- https://api.tracker.local/api
1036+
1037+
Grafana (HTTPS via Caddy):
1038+
https://grafana.tracker.local/
1039+
1040+
Prometheus:
1041+
Internal only (localhost:9090) - not exposed externally
1042+
1043+
Note: HTTPS services require domain-based access. For local domains (*.local),
1044+
add the following to your /etc/hosts file:
1045+
1046+
10.140.190.214 api.tracker.local http1.tracker.local http2.tracker.local grafana.tracker.local
1047+
1048+
Internal ports (1212, 7070, 7071, 3000) are not directly accessible when TLS is enabled.
1049+
```
1050+
1051+
### Phase 8: Schema Generation (30 minutes)
8991052

9001053
- [ ] Regenerate JSON schema from Rust DTOs:
9011054

@@ -908,7 +1061,7 @@ caddy 80/tcp, 443/tcp, 443/udp # Entry point for HTTPS
9081061
- [ ] Test schema with example HTTPS-enabled environment file
9091062
- [ ] Commit updated schema file
9101063

911-
### Phase 8: Create ADR (1 hour)
1064+
### Phase 9: Create ADR (1 hour)
9121065

9131066
- [ ] Create `docs/decisions/caddy-for-tls-termination.md`
9141067
- [ ] Document decision rationale (reference #270 evaluation)
@@ -977,6 +1130,20 @@ caddy 80/tcp, 443/tcp, 443/udp # Entry point for HTTPS
9771130
- [ ] Valid: no HTTPS configuration at all
9781131
- [ ] WebSocket connectivity tested through Caddy proxy
9791132

1133+
**CLI Command Compatibility**:
1134+
1135+
- [ ] `test` command works correctly with HTTPS-enabled services:
1136+
- [ ] Uses HTTPS domain URLs for TLS-enabled services
1137+
- [ ] Uses direct IP/port for non-TLS services
1138+
- [ ] Accepts self-signed certificates for local domains (e.g., `*.local`)
1139+
- [ ] Shows clear message indicating HTTPS test mode
1140+
- [ ] `show` command displays correct endpoints:
1141+
- [ ] Shows HTTPS URLs with domains for TLS-enabled services
1142+
- [ ] Shows direct IP/port for non-TLS services
1143+
- [ ] Includes note about domain-based access requirement
1144+
- [ ] Provides `/etc/hosts` configuration hint for local domains
1145+
- [ ] Clarifies internal ports are not accessible when TLS is enabled
1146+
9801147
**Production Verification**:
9811148

9821149
- [ ] Test deployment with all services HTTPS enabled

0 commit comments

Comments
 (0)