Skip to content

Commit 9e94344

Browse files
committed
docs: Update SSL configuration instructions in .env.example, README, and CONFIGURATION.md
- Enhanced the .env.example file with detailed comments on SSL setup for both local and production environments. - Updated README to clarify HTTPS configuration steps and the use of SSL certificates. - Revised CONFIGURATION.md to provide a comprehensive overview of SSL/TLS settings and usage instructions for Docker Compose.
1 parent d356ecf commit 9e94344

5 files changed

Lines changed: 74 additions & 23 deletions

File tree

.env.example

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,26 @@ MINIO_SECRET_KEY=minioadmin
3232
# SANDBOX_UID=1002 # Shared host UID for all sandbox languages
3333

3434
# ── Port ──────────────────────────────────────────────────────
35-
# PORT=8000 # External port the API is reachable on
35+
# PORT=8000 # External host port published by docker compose
3636

3737
# ── SSL/HTTPS ──────────────────────────────────────────────────
38-
# ENABLE_HTTPS=false
39-
# SSL_CERT_FILE=/path/to/cert.pem
40-
# SSL_KEY_FILE=/path/to/key.pem
38+
# HTTPS works the same with docker-compose.yml and docker-compose.prod.yml:
39+
# 1. SSL_CERTS_PATH is a host path mounted to /app/ssl inside the container
40+
# 2. SSL_CERT_FILE and SSL_KEY_FILE must be container paths under /app/ssl
41+
#
42+
# Simple local/self-managed cert directory:
43+
# PORT=443
44+
# ENABLE_HTTPS=true
45+
# SSL_CERTS_PATH=./ssl
46+
# SSL_CERT_FILE=/app/ssl/fullchain.pem
47+
# SSL_KEY_FILE=/app/ssl/privkey.pem
48+
#
49+
# Let's Encrypt on the host:
50+
# PORT=443
51+
# ENABLE_HTTPS=true
52+
# SSL_CERTS_PATH=/etc/letsencrypt
53+
# SSL_CERT_FILE=/app/ssl/live/example.com/fullchain.pem
54+
# SSL_KEY_FILE=/app/ssl/live/example.com/privkey.pem
4155

4256
# ── Logging ────────────────────────────────────────────────────
4357
# LOG_LEVEL=INFO # INFO = clean (1 log per execution); DEBUG = full detail

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Most users should run the published Docker image from GHCR. You do not need to b
4747
The API will be available at `http://localhost:8000`.
4848
Visit `http://localhost:8000/docs` for the interactive API documentation.
4949

50+
To enable HTTPS with either compose file, set `PORT`, `ENABLE_HTTPS`, `SSL_CERTS_PATH`, `SSL_CERT_FILE`, and `SSL_KEY_FILE` in `.env`. `SSL_CERTS_PATH` is the host path mounted into the container at `/app/ssl`, while `SSL_CERT_FILE` and `SSL_KEY_FILE` must point to the certificate files inside the container. See [docs/CONFIGURATION.md](docs/CONFIGURATION.md#sslhttps-configuration).
51+
5052
### Common Consumer Commands
5153

5254
```bash
@@ -96,7 +98,7 @@ The dashboard requires the master API key for authentication.
9698
- **Session Management**: Redis-based session handling with automatic cleanup
9799
- **S3-Compatible Storage**: MinIO integration for persistent file storage
98100
- **Authentication**: API key-based authentication for secure access
99-
- **HTTPS/SSL Support**: Optional SSL/TLS encryption with automatic HTTP to HTTPS redirection
101+
- **HTTPS/SSL Support**: Optional in-container SSL/TLS termination for both compose workflows
100102
- **Health Monitoring**: Comprehensive health check endpoints for all dependencies
101103
- **Metrics Collection**: Execution and API metrics for monitoring and debugging
102104
- **Unicode Support**: Full Unicode filename support in file downloads

docker-compose.prod.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ services:
1818
- MINIO_ENDPOINT=minio:9000
1919
volumes:
2020
- sandbox-data:/var/lib/code-interpreter/sandboxes
21+
# SSL_CERTS_PATH is a host path; SSL_CERT_FILE and SSL_KEY_FILE must point
22+
# to the mounted files inside the container under /app/ssl.
2123
- ${SSL_CERTS_PATH:-./ssl}:/app/ssl:ro
2224
tmpfs:
2325
- /app/data:size=100m

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ services:
2727
- MINIO_ENDPOINT=minio:9000
2828
volumes:
2929
- sandbox-data:/var/lib/code-interpreter/sandboxes
30+
# SSL_CERTS_PATH is a host path; SSL_CERT_FILE and SSL_KEY_FILE must point
31+
# to the mounted files inside the container under /app/ssl.
3032
- ${SSL_CERTS_PATH:-./ssl}:/app/ssl:ro
3133
tmpfs:
3234
- /app/data:size=100m

docs/CONFIGURATION.md

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,73 @@ Controls the basic API server settings.
4343

4444
Configures SSL/TLS support for secure HTTPS connections.
4545

46-
| Variable | Default | Description |
47-
| ---------------- | -------- | -------------------------------------------------------- |
48-
| `ENABLE_HTTPS` | `false` | Enable HTTPS/SSL support |
49-
| `SSL_CERTS_PATH` | `./ssl` | Host path to directory containing `cert.pem` and `key.pem` |
50-
51-
> **Note:** The certificate files are automatically mapped to `/app/ssl/` inside the API container via `docker-compose.yml`. You only need to set `SSL_CERTS_PATH` to point to your certificates directory on the host.
46+
Both `docker-compose.yml` and `docker-compose.prod.yml` use the same HTTPS contract:
47+
48+
- `PORT` is the external host port published by Docker.
49+
- `SSL_CERTS_PATH` is a host path mounted into the API container at `/app/ssl`.
50+
- `SSL_CERT_FILE` and `SSL_KEY_FILE` are paths inside the container.
51+
- For predictable restarts, set `ENABLE_HTTPS=true` explicitly instead of relying on auto-detection.
52+
53+
| Variable | Default | Description |
54+
| ---------------- | ---------------------- | ----------- |
55+
| `PORT` | `8000` | External host port published by Docker Compose |
56+
| `ENABLE_HTTPS` | auto | When unset, HTTPS auto-enables only if the configured cert and key files exist inside the container |
57+
| `SSL_CERTS_PATH` | `./ssl` | Host path mounted into the container at `/app/ssl` |
58+
| `SSL_CERT_FILE` | `/app/ssl/fullchain.pem` | Certificate file path inside the container |
59+
| `SSL_KEY_FILE` | `/app/ssl/privkey.pem` | Private key file path inside the container |
60+
| `SSL_CA_CERTS` | - | Optional CA bundle path inside the container |
5261

5362
**HTTPS Setup:**
5463

55-
1. **Generate or obtain SSL certificates**:
64+
1. **Use a simple cert directory on the host**:
5665

5766
```bash
58-
# For development (self-signed certificate)
59-
mkdir ssl
60-
openssl req -x509 -newkey rsa:4096 -nodes -out ssl/cert.pem -keyout ssl/key.pem -days 365
61-
62-
# For production, use certificates from a trusted CA
67+
mkdir -p ssl
68+
openssl req -x509 -newkey rsa:4096 -nodes \
69+
-out ssl/fullchain.pem \
70+
-keyout ssl/privkey.pem \
71+
-days 365
6372
```
6473

65-
2. **Configure HTTPS in .env**:
74+
Then set:
6675

6776
```bash
77+
PORT=443
6878
ENABLE_HTTPS=true
79+
SSL_CERTS_PATH=./ssl
80+
SSL_CERT_FILE=/app/ssl/fullchain.pem
81+
SSL_KEY_FILE=/app/ssl/privkey.pem
82+
```
83+
84+
2. **Use Let's Encrypt from the host**:
6985

70-
# If using the default ./ssl directory, no additional config needed.
71-
# If your certs are elsewhere, set the path:
72-
# SSL_CERTS_PATH=/path/to/your/ssl/certs
86+
If the host already has certificates in `/etc/letsencrypt`, mount that tree and point the app at the files inside `/app/ssl`:
87+
88+
```bash
89+
PORT=443
90+
ENABLE_HTTPS=true
91+
SSL_CERTS_PATH=/etc/letsencrypt
92+
SSL_CERT_FILE=/app/ssl/live/example.com/fullchain.pem
93+
SSL_KEY_FILE=/app/ssl/live/example.com/privkey.pem
7394
```
7495

75-
The directory must contain files named `cert.pem` and `key.pem`.
96+
3. **Start the stack with either compose file**:
7697

77-
3. **Deploy with docker compose**:
7898
```bash
7999
docker compose up -d
100+
101+
# or
102+
docker compose -f docker-compose.prod.yml up -d
103+
```
104+
105+
4. **Verify HTTPS**:
106+
107+
```bash
108+
curl -fsk https://localhost/health
80109
```
81110

111+
If you terminate TLS at an external reverse proxy instead, keep the API on HTTP by leaving `ENABLE_HTTPS` unset or setting it to `false`, and publish the proxy on `443` instead of the API container.
112+
82113
**Security Notes:**
83114

84115
- Use certificates from trusted Certificate Authorities in production

0 commit comments

Comments
 (0)