Skip to content

Commit bf5df90

Browse files
committed
docs: [#272] Add HTTPS user documentation
- Create docs/user-guide/services/https.md with complete HTTPS setup guide - Document domain + use_tls_proxy configuration pattern for each service - Add Let's Encrypt production vs staging documentation - Add configuration examples for various HTTPS patterns - Add troubleshooting section for common certificate issues - Update services README to include HTTPS as an available service - Update main user guide README with HTTPS service reference - Update grafana.md with TLS proxy configuration fields - Regenerate JSON schema to reflect current implementation
1 parent 2426650 commit bf5df90

File tree

8 files changed

+612
-58
lines changed

8 files changed

+612
-58
lines changed

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

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ Production deployment at `/opt/torrust/` on Hetzner server (46.224.206.37) serve
2323
- [x] Support HTTPS for all HTTP services (Tracker API, HTTP Tracker, Grafana)
2424
- [x] Enable automatic Let's Encrypt certificate management
2525
- [x] Add HTTPS configuration to environment schema
26-
- [ ] Implement security scanning for Caddy in CI/CD
27-
- [ ] Document HTTPS setup in user guide
26+
- [x] Implement security scanning for Caddy in CI/CD
27+
- [x] Document HTTPS setup in user guide
2828
- [ ] Add E2E tests for HTTPS functionality
2929

3030
## 🏗️ Architecture Requirements
@@ -684,27 +684,24 @@ Add link to HTTPS setup guide.
684684

685685
### Phase 5: Documentation (4-5 hours)
686686

687-
- [ ] Create `docs/user-guide/https-setup.md` with complete setup guide:
688-
- [ ] Prerequisites (domain names, DNS configuration)
689-
- [ ] **Configuration patterns**: All services, single service, multiple trackers
690-
- [ ] **Selective HTTPS**: How to enable HTTPS for some services but not others
691-
- [ ] **Multiple HTTP trackers**: Configuration examples with mixed HTTPS/HTTP
692-
- [ ] Environment configuration examples for each pattern
693-
- [ ] Let's Encrypt certificate process
694-
- [ ] **Let's Encrypt staging environment**: Document `use_staging: true` for testing (avoids rate limits)
695-
- [ ] **Rate limits**: Document Let's Encrypt limits (50 certs/week, 5 duplicates/week)
696-
- [ ] **Staging certificates warning**: Browser warnings expected (not trusted), only for testing
697-
- [ ] Troubleshooting common issues
698-
- [ ] Certificate renewal (automatic)
699-
- [ ] Domain verification requirements
700-
- [ ] Update `docs/user-guide/README.md` with HTTPS guide link
701-
- [ ] Update `docs/user-guide/configuration.md` with HTTPS config examples:
702-
- [ ] Example: HTTPS only for API (sensitive token)
703-
- [ ] Example: Multiple trackers, selective HTTPS
704-
- [ ] Example: VPN deployment without HTTPS
705-
- [ ] Create example environment files in `envs/` demonstrating patterns
706-
- [ ] Add troubleshooting section for common certificate issues
707-
- [ ] Document Let's Encrypt rate limits and best practices
687+
- [x] Create `docs/user-guide/services/https.md` with complete HTTPS setup guide:
688+
- [x] Overview of HTTPS architecture with Caddy
689+
- [x] Prerequisites (domain names, DNS configuration, firewall)
690+
- [x] **Global HTTPS configuration**: `admin_email` and `use_staging` options
691+
- [x] **Per-service TLS configuration**: `domain` and `use_tls_proxy` pattern
692+
- [x] Services supporting HTTPS (Tracker HTTP API, HTTP Trackers, Health Check API, Grafana)
693+
- [x] Let's Encrypt certificate process (automatic acquisition and renewal)
694+
- [x] **Let's Encrypt staging environment**: Document `use_staging: true` for testing (avoids rate limits)
695+
- [x] **Rate limits**: Document Let's Encrypt limits (50 certs/week, 5 duplicates/week)
696+
- [x] **Staging certificates warning**: Browser warnings expected (not trusted), only for testing
697+
- [x] Complete configuration example with all services HTTPS-enabled
698+
- [x] Verification commands for checking HTTPS functionality
699+
- [x] Troubleshooting section (DNS, firewall, certificates, Caddy logs)
700+
- [x] Architecture explanation (Caddy as TLS termination proxy)
701+
- [x] Update `docs/user-guide/services/README.md` with HTTPS service entry
702+
- [x] Update `docs/user-guide/README.md` with HTTPS reference in services section
703+
- [x] Update `docs/user-guide/services/grafana.md` with TLS proxy fields documentation
704+
- [x] Regenerate JSON schema (`schemas/environment-config.json`)
708705

709706
### Phase 6: E2E Testing (5-6 hours)
710707

@@ -1483,20 +1480,20 @@ The implementation is split into incremental steps, one service type at a time,
14831480
- [x] Remove `domain::tls` module completely (unused after migration)
14841481
- [x] Run full E2E test suite
14851482
- [x] Run all linters
1486-
- [ ] Manual verification with `envs/manual-https-test.json`
1483+
- [x] Manual verification with `envs/manual-https-test.json`
14871484

14881485
### Phase 8: Schema Generation (30 minutes)
14891486

1490-
- [ ] Regenerate JSON schema from Rust DTOs:
1487+
- [x] Regenerate JSON schema from Rust DTOs:
14911488

14921489
```bash
14931490
cargo run --bin torrust-tracker-deployer -- create schema > schemas/environment-config.json
14941491
```
14951492

1496-
- [ ] Verify schema includes HTTPS configuration section
1497-
- [ ] Verify schema validation rules match Rust DTO constraints
1498-
- [ ] Test schema with example HTTPS-enabled environment file
1499-
- [ ] Commit updated schema file
1493+
- [x] Verify schema includes HTTPS configuration section
1494+
- [x] Verify schema validation rules match Rust DTO constraints
1495+
- [x] Test schema with example HTTPS-enabled environment file
1496+
- [x] Commit updated schema file
15001497

15011498
### Phase 9: Create ADR (1 hour)
15021499

docs/user-guide/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,13 @@ The Torrust Tracker Deployer supports optional services that can be enabled in y
308308

309309
### Available Services
310310

311-
- **[Prometheus Monitoring](services/prometheus.md)** - Metrics collection and monitoring (enabled by default)
311+
- **[HTTPS Support](services/https.md)** - Automatic TLS/SSL with Let's Encrypt (disabled by default)
312+
- Automatic certificate management via Caddy reverse proxy
313+
- Per-service TLS configuration (API, HTTP trackers, Health Check API, Grafana)
314+
- HTTP/2 and HTTP/3 support
315+
- Enabled by adding `domain` and `use_tls_proxy: true` to individual services
312316

317+
- **[Prometheus Monitoring](services/prometheus.md)** - Metrics collection and monitoring (enabled by default)
313318
- Automatic metrics scraping from tracker API
314319
- Web UI on port 9090
315320
- Configurable scrape intervals

docs/user-guide/services/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,14 @@ The services documentation provides comprehensive guides for each optional servi
1414

1515
## Available Services
1616

17-
- **[Prometheus Monitoring](prometheus.md)** - Metrics collection and monitoring service
17+
- **[HTTPS Support](https.md)** - Automatic TLS/SSL with Let's Encrypt
18+
- Automatic certificate management via Caddy reverse proxy
19+
- Per-service TLS configuration (API, HTTP trackers, Health Check API, Grafana)
20+
- HTTP/2 and HTTP/3 support
21+
- Automatic HTTP to HTTPS redirect
22+
- Disabled by default, enabled by adding `domain` and `use_tls_proxy: true` to services
1823

24+
- **[Prometheus Monitoring](prometheus.md)** - Metrics collection and monitoring service
1925
- Automatic metrics scraping from tracker API endpoints
2026
- Web UI for querying and visualizing metrics
2127
- Configurable scrape intervals
@@ -92,8 +98,6 @@ To exclude a service from your deployment, simply remove its configuration secti
9298

9399
As the deployer evolves, additional optional services may be added to this directory:
94100

95-
- Database services (MySQL, PostgreSQL)
96-
- Reverse proxy services (Nginx, Traefik)
97101
- Logging aggregation (Loki, Elasticsearch)
98102
- Alerting services (Alertmanager)
99103

docs/user-guide/services/grafana.md

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,26 +49,43 @@ Add the `grafana` section to your environment configuration file:
4949
- Default: `admin`
5050
- **⚠️ SECURITY WARNING**: Always change the default password before deploying to production environments
5151

52+
**grafana.domain** (optional):
53+
54+
- Domain name for HTTPS access via Caddy reverse proxy
55+
- When present with `use_tls_proxy: true`, Grafana is accessible via HTTPS at this domain
56+
- Caddy automatically obtains and renews TLS certificates
57+
58+
**grafana.use_tls_proxy** (optional):
59+
60+
- Boolean to enable HTTPS via Caddy reverse proxy
61+
- Default: `false` (HTTP only)
62+
- Requires `domain` to be set
63+
- When enabled, port 3100 is not exposed; access is via HTTPS (port 443)
64+
5265
**Examples**:
5366

5467
```json
55-
// Development environment (simple credentials)
68+
// Development environment (HTTP only)
5669
{
5770
"grafana": {
5871
"admin_user": "admin",
5972
"admin_password": "devpass123"
6073
}
6174
}
6275

63-
// Production environment (strong credentials)
76+
// Production environment with HTTPS
6477
{
6578
"grafana": {
6679
"admin_user": "grafana-admin",
67-
"admin_password": "Str0ng!P@ssw0rd#2024"
80+
"admin_password": "Str0ng!P@ssw0rd#2024",
81+
"domain": "grafana.example.com",
82+
"use_tls_proxy": true
6883
}
6984
}
7085
```
7186

87+
> **Note**: When using HTTPS, you must also configure the global `https` section with `admin_email`. See the [HTTPS Guide](https.md) for complete documentation.
88+
7289
**Real Example**: See [`envs/manual-test-grafana.json`](../../../envs/manual-test-grafana.json) for a working configuration.
7390

7491
### Prometheus Dependency
@@ -117,23 +134,32 @@ To deploy without Grafana visualization, remove the entire `grafana` section fro
117134

118135
After deployment, the Grafana web UI is available at:
119136

137+
**HTTP (default)**:
138+
120139
```text
121140
http://<vm-ip>:3100
122141
```
123142

124-
Where `<vm-ip>` is the IP address of your deployed VM instance.
143+
**HTTPS (when TLS enabled)**:
144+
145+
```text
146+
https://<your-domain>
147+
```
148+
149+
Where `<vm-ip>` is the IP address of your deployed VM instance and `<your-domain>` is the configured domain (e.g., `grafana.example.com`).
125150

126151
### Finding Your VM IP
127152

128-
```bash
129-
# Extract IP from environment state
130-
cat data/<env-name>/environment.json | grep ip_address
153+
Use the `show` command to display environment information including the VM IP:
131154

132-
# Or use jq for cleaner output
133-
INSTANCE_IP=$(cat data/<env-name>/environment.json | jq -r '.Running.context.runtime_outputs.instance_ip')
134-
echo "Grafana UI: http://$INSTANCE_IP:3100"
155+
```bash
156+
torrust-tracker-deployer show <env-name>
135157
```
136158

159+
Look for the "Instance IP" field in the output.
160+
161+
> **Note**: JSON output format is planned for future releases to enable scripting.
162+
137163
### First Login
138164

139165
1. Open `http://<vm-ip>:3100` in your web browser
@@ -151,17 +177,14 @@ echo "Grafana UI: http://$INSTANCE_IP:3100"
151177
After first login, you need to add Prometheus as a datasource:
152178

153179
1. **Navigate to Configuration**:
154-
155180
- Click the gear icon (⚙️) in the left sidebar
156181
- Select **Data Sources**
157182

158183
2. **Add New Datasource**:
159-
160184
- Click **Add data source**
161185
- Select **Prometheus** from the list
162186

163187
3. **Configure Datasource**:
164-
165188
- **Name**: `Prometheus` (or any name you prefer)
166189
- **URL**: `http://prometheus:9090`
167190
- **Access**: `Server (default)`
@@ -184,7 +207,6 @@ The Torrust project provides two sample dashboards for visualizing tracker metri
184207
#### Available Dashboards
185208

186209
1. **stats.json** - Statistics Dashboard
187-
188210
- Displays data from the `/api/v1/stats` tracker endpoint
189211
- Shows high-level tracker statistics
190212
- Good for general monitoring
@@ -199,17 +221,14 @@ The Torrust project provides two sample dashboards for visualizing tracker metri
199221
#### Import Process
200222

201223
1. **Navigate to Dashboards**:
202-
203224
- Click the **+** icon in the left sidebar
204225
- Select **Import**
205226

206227
2. **Upload Dashboard**:
207-
208228
- Click **Upload JSON file** and select the dashboard file
209229
- Or paste the JSON content directly into the text area
210230

211231
3. **Configure Import**:
212-
213232
- **Name**: Keep the default or customize
214233
- **Folder**: Select a folder or leave as default
215234
- **Prometheus**: Select the datasource you created earlier
@@ -254,16 +273,13 @@ After importing, you can:
254273
### Creating Custom Dashboards
255274

256275
1. **New Dashboard**:
257-
258276
- Click **+** icon → **Dashboard**
259277
- Click **Add visualization**
260278

261279
2. **Select Data Source**:
262-
263280
- Choose your Prometheus datasource
264281

265282
3. **Write Query**:
266-
267283
- Use Prometheus query language (PromQL)
268284
- Examples:
269285

@@ -279,7 +295,6 @@ After importing, you can:
279295
```
280296
281297
4. **Customize Visualization**:
282-
283298
- Choose panel type (Graph, Stat, Gauge, Table, etc.)
284299
- Set thresholds and colors
285300
- Add units and labels
@@ -501,13 +516,11 @@ services:
501516
A separate issue is planned to add:
502517
503518
1. **Auto-Provision Prometheus Datasource**:
504-
505519
- Automatically create datasource during deployment
506520
- Zero-config experience for users
507521
- No manual setup steps required
508522
509523
2. **Auto-Import Tracker Dashboards**:
510-
511524
- Automatically import `stats.json` and `metrics.json`
512525
- Dashboards available immediately after deployment
513526
- Provisioning via `provisioning/dashboards/` directory
@@ -525,6 +538,7 @@ A separate issue is planned to add:
525538

526539
## Related Documentation
527540

541+
- **[HTTPS Guide](https.md)** - Enable HTTPS with automatic TLS certificates
528542
- **[Prometheus Service Guide](prometheus.md)** - Metrics collection service
529543
- **[Manual Verification Guide](../../e2e-testing/manual/grafana-verification.md)** - Detailed verification steps
530544
- **[Grafana Integration ADR](../../decisions/grafana-integration-pattern.md)** - Design decisions and rationale

0 commit comments

Comments
 (0)