Skip to content

Commit 6c8e0d9

Browse files
authored
Merge pull request #45 from Dstack-TEE/ingress-sec
feat: hardened dstack-ingress
2 parents 13c5325 + f523ad3 commit 6c8e0d9

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

custom-domain/dstack-ingress/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project enables you to run dstack applications with your own custom domain,
1010
- Cloudflare DNS configuration for CNAME, TXT, and CAA records
1111
- Nginx reverse proxy to route traffic to your application
1212
- Certificate evidence generation for verification
13+
- Strong SSL/TLS configuration with modern cipher suites (AES-GCM and ChaCha20-Poly1305)
1314

1415
## How It Works
1516

@@ -87,16 +88,24 @@ Explanation of environment variables:
8788
If you prefer to build the image yourself:
8889

8990
1. Clone this repository
90-
2. Build the Docker image:
91+
2. Build the Docker image using the provided build script:
9192

9293
```bash
93-
docker build -t yourusername/dstack-ingress .
94+
./build-image.sh yourusername/dstack-ingress:tag
9495
```
9596

97+
**Important**: You must use the `build-image.sh` script to build the image. This script ensures reproducible builds with:
98+
- Specific buildkit version (v0.20.2)
99+
- Deterministic timestamps (`SOURCE_DATE_EPOCH=0`)
100+
- Package pinning for consistency
101+
- Git revision tracking
102+
103+
Direct `docker build` commands will not work properly due to the specialized build requirements.
104+
96105
3. Push to your registry (optional):
97106

98107
```bash
99-
docker push yourusername/dstack-ingress
108+
docker push yourusername/dstack-ingress:tag
100109
```
101110

102111
4. Update the docker-compose.yaml file with your image name and deploy

custom-domain/dstack-ingress/scripts/entrypoint.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,49 @@ setup_nginx_conf() {
1616
cat <<EOF > /etc/nginx/conf.d/default.conf
1717
server {
1818
listen ${PORT} ssl;
19+
http2 on;
1920
server_name ${DOMAIN};
2021
22+
# SSL certificate configuration
2123
ssl_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
2224
ssl_certificate_key /etc/letsencrypt/live/${DOMAIN}/privkey.pem;
2325
26+
# Modern SSL configuration - TLS 1.2 and 1.3 only
27+
ssl_protocols TLSv1.2 TLSv1.3;
28+
29+
# Strong cipher suites - Only AES-GCM and ChaCha20-Poly1305
30+
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305';
31+
32+
# Prefer server cipher suites
33+
ssl_prefer_server_ciphers on;
34+
35+
# ECDH curve for ECDHE ciphers
36+
ssl_ecdh_curve secp384r1;
37+
38+
# Enable OCSP stapling
39+
ssl_stapling on;
40+
ssl_stapling_verify on;
41+
ssl_trusted_certificate /etc/letsencrypt/live/${DOMAIN}/fullchain.pem;
42+
resolver 8.8.8.8 8.8.4.4 valid=300s;
43+
resolver_timeout 5s;
44+
45+
# SSL session configuration
46+
ssl_session_timeout 1d;
47+
ssl_session_cache shared:SSL:50m;
48+
ssl_session_tickets off;
49+
50+
# SSL buffer size (optimized for TLS 1.3)
51+
ssl_buffer_size 4k;
52+
53+
# Disable SSL renegotiation
54+
ssl_early_data off;
55+
2456
location / {
2557
proxy_pass ${TARGET_ENDPOINT};
58+
proxy_set_header Host \$host;
59+
proxy_set_header X-Real-IP \$remote_addr;
60+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
61+
proxy_set_header X-Forwarded-Proto \$scheme;
2662
}
2763
2864
location /evidences/ {

0 commit comments

Comments
 (0)