π SSL/TLS Termination β What It Means¶
SSL/TLS termination means:
-
Client connects to NGINX via HTTPS
-
NGINX decrypts the traffic
-
Sends plain HTTP internally to your backend services
Benefits:
β Backend doesnβt need SSL
β Faster performance
β Central place for certificates
β Easy renewal + rotation
β Works well in microservices
π§± 1. Requirements¶
You need:
-
A domain β example.com
-
A server β Ubuntu / Debian / CentOS
-
NGINX installed
-
Port 80 and 443 open
π 2. Install NGINX¶
π 3. Install Certbot (Free SSL β Letβs Encrypt)¶
π 4. Create Reverse Proxy (Before SSL)¶
Example backend:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Enable:
sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
π₯ 5. Enable SSL/TLS Termination¶
Run Certbot:
Certbot will:
β Install SSL
β Configure HTTPS
β Redirect HTTP β HTTPS automatically
β Create renewal cron
β Generate cert files
π 6. Final NGINX SSL Configuration¶
Certbot will generate something like:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name example.com www.example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
}
}
NGINX TERMINATES SSL HERE
β
Backend receives HTTP.
π§ͺ 7. Test SSL¶
You should see:
Check certificate:
π 8. Auto Renewal¶
Certbot auto-renews daily.
You can test:
π‘ 9. Strengthen HTTPS Security¶
Add inside your HTTPS server block:
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_stapling on;
ssl_stapling_verify on;
π§° 10. Disable Old TLS Versions (Optional)¶
You get:
β Higher score on SSL Labs
β Better security
π₯ 11. HTTP β HTTPS Redirect (Manual Version)¶
If Certbot didnβt create redirect:
π― 12. Using Self-Signed Certificate (Local Testing)¶
sudo openssl req -x509 -newkey rsa:4096 -nodes \
-keyout /etc/nginx/self.key \
-out /etc/nginx/self.crt \
-days 365
Then configure:
π SSL/TLS Termination Setup Complete!¶
You now have:
β HTTPS enabled
β SSL termination at NGINX
β Backend remains HTTP
β Automatic certificate renewal
β Hardened TLS configuration
β Security best practices