Configure SSL/TLS certificates for secure HTTPS connections with automatic certificate generation, green lock browser compatibility, and comprehensive SSL management.
*.localhost
and *.local.nself.org
nself trust
, nself ssl bootstrap/renew/status
nself provides comprehensive SSL/TLS support with automatic certificate generation, browser trust management, and production-ready SSL configuration. All services now run with HTTPS by default, ensuring secure connections from development to production.
Starting with v0.3.5, SSL is enabled automatically and nself supports dual domain configurations for maximum compatibility:
*.localhost
domains with automatic browser trust*.local.nself.org
domains for team sharingThe easiest way to get SSL certificates for production:
# In your .env.local or .env production file:
SSL_MODE=letsencrypt
LETSENCRYPT_EMAIL=admin@yourdomain.com
DOMAIN=yourdomain.com
# Optional: Multiple domains
ADDITIONAL_DOMAINS=www.yourdomain.com,api.yourdomain.com
# Rebuild and start
nself build && nself up
Let's Encrypt certificates are automatically renewed:
# Automatic renewal (default)
SSL_AUTO_RENEW=true
SSL_RENEW_DAYS=30 # Renew when 30 days or less remain
nself v0.3.5 introduces comprehensive SSL management commands:
# Bootstrap SSL certificates (initial setup)
nself ssl bootstrap
# Check SSL certificate status
nself ssl status
# Renew public certificates (Let's Encrypt)
nself ssl renew
# Check trust status
nself trust status
If 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.key
✨ Enhanced in v0.3.5: Complete automatic SSL setup with dual domain support and green lock compatibility!
Get trusted SSL certificates for all your services with a single command:
# Install SSL certificate authority and enable browser trust
nself trust
# Check trust status
nself trust status
# Your services are now accessible with green lock at:
# Localhost domains (fastest):
# - https://hasura.localhost
# - https://auth.localhost
# - https://dashboard.localhost
# - https://mailpit.localhost
# Network-accessible domains:
# - https://hasura.local.nself.org
# - https://auth.local.nself.org
# - https://dashboard.local.nself.org
# - https://mailpit.local.nself.org
*.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.org
If 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.com
Test 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=false
SSL 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.sh
Automated 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