Updated for nself v0.4.8
Configure SSL/TLS certificates for secure HTTPS connections with the new nself prod ssl commands, automatic certificate management, and green lock browser compatibility.
nself provides comprehensive SSL/TLS support with automatic certificate generation, browser trust management, and production-ready SSL configuration. All services run with HTTPS by default, ensuring secure connections from development to production.
SSL configuration by environment:
*.local.nself.org with nself trust for browser trust--staging flag to avoid rate limitsnself prod sslnself v0.4.8 introduces comprehensive SSL management via nself prod ssl:
# Check current SSL certificate status
nself prod ssl status
# Shows: subject, issuer, validity dates, days until expiry
# Request a Let's Encrypt certificate
nself prod ssl request yourdomain.com --email admin@yourdomain.com
# Use staging for testing (avoids rate limits)
nself prod ssl request yourdomain.com --staging
# Request with multiple domains
nself prod ssl request yourdomain.com,www.yourdomain.com,api.yourdomain.comRenew certificates before they expire:
# Renew SSL certificates
nself prod ssl renew
# Force renewal even if not near expiry
nself prod ssl renew --force
# Certificate expiry is shown in status:
nself prod ssl status
# Expires in: 45 daysVerify certificate chain and configuration:
# Verify certificate chain matches private key
nself prod ssl verify
# What it checks:
# - Certificate file exists
# - Private key file exists
# - Certificate chain is valid
# - Certificate matches private keyIf you have certificates from a Certificate Authority:
# Configure custom SSL
SSL_MODE=custom
SSL_CERT_PATH=/path/to/certificate.crt
SSL_KEY_PATH=/path/to/private.key
SSL_CHAIN_PATH=/path/to/chain.crt # Optional intermediate certificate
# Place certificates in ssl/ directory
mkdir -p ssl/
cp your-cert.crt ssl/certificate.crt
cp your-key.key ssl/private.key
cp your-chain.crt ssl/chain.crt# For wildcard certificates (*.yourdomain.com)
SSL_MODE=custom
DOMAIN=yourdomain.com
WILDCARD_CERT=true
SSL_CERT_PATH=ssl/wildcard.crt
SSL_KEY_PATH=ssl/wildcard.keynself trust installs a local CA certificate for trusted HTTPS in development.
Get trusted SSL certificates for all your services with a single command:
# Install SSL certificate authority and enable browser trust
nself trust
# Your services are now accessible with green lock at:
# - https://api.local.nself.org # Hasura GraphQL
# - https://auth.local.nself.org # Authentication
# - https://admin.local.nself.org # nself-admin
# - https://storage.local.nself.org # MinIO
# - https://mail.local.nself.org # MailPit
# Generate self-signed certificate for a custom domain
nself prod ssl self-signed mydomain.local*.localhost and *.local.nself.org💡 Pro Tip: Run nself trust once per machine. The certificates work for all your nself projects automatically.
For local development with basic HTTPS (will show browser warnings):
# Enable development SSL
SSL_MODE=self-signed
DOMAIN=local.nself.org
# nself will generate certificates automatically
# Access your app at https://local.nself.orgIf you prefer manual setup or need custom configuration:
# Manual mkcert setup
# Install mkcert
brew install mkcert # macOS
sudo apt install mkcert # Ubuntu
# Create local CA
mkcert -install
# Generate certificates
mkcert local.nself.org "*.local.nself.org"
# Configure nself
SSL_MODE=custom
SSL_CERT_PATH=ssl/local.nself.org.pem
SSL_KEY_PATH=ssl/local.nself.org-key.pem# SSL security configuration
SSL_PROTOCOLS=TLSv1.2 TLSv1.3
SSL_CIPHERS=ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512
SSL_PREFER_SERVER_CIPHERS=on
SSL_SESSION_CACHE=shared:SSL:10m
SSL_SESSION_TIMEOUT=10m
# HSTS (HTTP Strict Transport Security)
HSTS_ENABLED=true
HSTS_MAX_AGE=31536000 # 1 year
HSTS_INCLUDE_SUBDOMAINS=true
HSTS_PRELOAD=true# Strict certificate validation
SSL_VERIFY_CLIENT=off
SSL_VERIFY_DEPTH=1
# OCSP stapling
SSL_STAPLING=on
SSL_STAPLING_VERIFY=on# Test SSL certificate
openssl s_client -connect yourdomain.com:443 -servername yourdomain.com
# Check certificate details
openssl x509 -in certificate.crt -text -noout
# Verify certificate expiration
openssl x509 -in certificate.crt -enddate -noout
# Test with curl
curl -I https://yourdomain.comTest your SSL configuration quality:
# Check nginx SSL configuration
nself exec nginx nginx -t
# View nginx error logs
nself logs nginx | grep ssl
# Verify certificate files exist and are readable
ls -la ssl/
chmod 644 ssl/*.crt
chmod 600 ssl/*.key# If you hit rate limits:
# - Wait for rate limit to reset (weekly for most limits)
# - Use staging environment for testing
SSL_STAGING=true # Use Let's Encrypt staging
# Then switch to production
SSL_STAGING=falseSSL Management: Use nself ssl status to check certificate health and nself ssl renew for manual renewal when needed.
# Ensure all content is served over HTTPS
# Check for:
# - HTTP links in HTML
# - HTTP API calls
# - HTTP resources (images, CSS, JS)
# Force HTTPS redirects
FORCE_HTTPS=true
HTTPS_REDIRECT=true# Subject Alternative Names (SAN)
DOMAIN=yourdomain.com
ADDITIONAL_DOMAINS=www.yourdomain.com,api.yourdomain.com,admin.yourdomain.com
# Separate certificates per subdomain
SSL_MULTI_CERT=true
SSL_CERT_API=/path/to/api-cert.crt
SSL_KEY_API=/path/to/api-key.key
SSL_CERT_ADMIN=/path/to/admin-cert.crt
SSL_KEY_ADMIN=/path/to/admin-key.key# Different certificate providers
SSL_MODE=letsencrypt # Free, automatic
SSL_MODE=cloudflare # Cloudflare Origin Certificate
SSL_MODE=custom # Your own certificates
SSL_MODE=self-signed # Development only# If using a load balancer for SSL termination
SSL_TERMINATION=loadbalancer
SSL_MODE=none
FORWARDED_PROTO_ENABLED=true
# Trust proxy headers
TRUST_PROXY=true
PROXY_IPS=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16# Monitor certificate expiration
#!/bin/bash
# check-ssl-expiry.sh
DOMAIN="yourdomain.com"
EXPIRY_DATE=$(openssl s_client -connect $DOMAIN:443 -servername $DOMAIN 2>/dev/null | openssl x509 -enddate -noout | cut -d= -f2)
EXPIRY_TIMESTAMP=$(date -d "$EXPIRY_DATE" +%s)
CURRENT_TIMESTAMP=$(date +%s)
DAYS_UNTIL_EXPIRY=$(( (EXPIRY_TIMESTAMP - CURRENT_TIMESTAMP) / 86400 ))
if [ $DAYS_UNTIL_EXPIRY -lt 30 ]; then
echo "SSL certificate expires in $DAYS_UNTIL_EXPIRY days" | mail -s "SSL Alert" admin@yourdomain.com
fi# Cron job for certificate renewal check
crontab -e
# Monitor certificate expiry weekly
0 9 * * 1 /path/to/check-ssl-expiry.shAutomated Renewal: Use nself ssl renew for manual renewal or set up automated scripts with the status commands.
# SSL session caching for performance
SSL_SESSION_CACHE=shared:SSL:10m
SSL_SESSION_TIMEOUT=10m
SSL_SESSION_TICKETS=on# Enable OCSP stapling for faster certificate validation
SSL_STAPLING=on
SSL_STAPLING_VERIFY=on
SSL_TRUSTED_CERTIFICATE=/path/to/chain.crt# Security headers for HTTPS
SECURITY_HEADERS_ENABLED=true
# Strict Transport Security
HSTS_ENABLED=true
HSTS_MAX_AGE=31536000
HSTS_INCLUDE_SUBDOMAINS=true
# Content Security Policy
CSP_ENABLED=true
CSP_UPGRADE_INSECURE_REQUESTS=true
# Secure cookie settings
SECURE_COOKIES=true
SAME_SITE_COOKIES=strict