- Point 5 (SSRF): Add URL validation for WELIST_SERVER_URL (src/validation.rs) - Point 6 (DB Access): Add DB path validation, symlink check, WAL mode (open_db) - Point 8 (HTTPS): Extract nginx config, add deployment checklist, bind warnings - Point 9 (Input Validation): Add NETWORKS check (404 for unknown), txid 64-hex validation - Optimize echo_push: parse transactions outside DB lock, batch duplicate check, N+1 xpub lookup eliminated via HashSet cache - Optimize echo_info: derive BIP32 address outside DB lock, minimize lock duration - Fix echo_stats SQL injection via parameter binding + add idx_stats_chain index - New regression tests: ssrf_tests, db_path_validation, input_validation_tests
56 lines
1.7 KiB
Plaintext
56 lines
1.7 KiB
Plaintext
# Nginx reverse proxy for bal-server
|
|
# Place this file in /etc/nginx/sites-available/ and symlink to sites-enabled
|
|
# Replace BAL_DOMAIN with your actual domain
|
|
|
|
# HTTP redirect to HTTPS
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name BAL_DOMAIN;
|
|
return 301 https://$server_name$request_uri;
|
|
}
|
|
|
|
# HTTPS proxy to bal-server (localhost only)
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name BAL_DOMAIN;
|
|
|
|
# Let's Encrypt certificates (managed by certbot)
|
|
ssl_certificate /etc/letsencrypt/live/BAL_DOMAIN/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/BAL_DOMAIN/privkey.pem;
|
|
|
|
# Security headers (no HSTS to avoid preloading issues)
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
# Body size limit — must match Actix PayloadConfig (default 1 MB)
|
|
client_max_body_size 1m;
|
|
|
|
# Rate limiting zone (requires `limit_req_zone` in nginx.conf)
|
|
# limit_req zone=bal burst=20 nodelay;
|
|
# limit_conn addr 10;
|
|
|
|
# Proxy to bal-server on localhost
|
|
location / {
|
|
proxy_pass http://127.0.0.1:9137;
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
proxy_connect_timeout 5s;
|
|
proxy_send_timeout 10s;
|
|
proxy_read_timeout 30s;
|
|
}
|
|
|
|
# Optional: serve public_key.pem directly from Nginx (faster)
|
|
# location /.pub_key.pem {
|
|
# alias /var/bal/public_key.pem;
|
|
# add_header Content-Type text/plain;
|
|
# }
|
|
}
|