Ravindra BagaleCourses & study guides

13. Multiple Websites on One Server and HTTPS with Certbot

13.5 Checking and Hardening Your TLS Setup

Padlock disla mhanje kaam sampla asa nahi. TLS versions, certificate aani security headers check karuya.

openssl s_client -connect yourdomain.com:443 -servername yourdomain.com </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates
openssl s_client -connect yourdomain.com:443 -tls1_1 </dev/null     # should FAIL (old version)
curl -sI https://yourdomain.com | grep -i strict-transport
# Nginx – inside the 443 server block (Certbot creates it)
ssl_protocols TLSv1.2 TLSv1.3;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
# Apache – inside <VirtualHost *:443> (needs: sudo a2enmod headers on Ubuntu)
SSLProtocol -all +TLSv1.2 +TLSv1.3
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Check Good result
Protocols Only TLS 1.2 and 1.3
Certificate Matches the domain, not expired, full chain
Redirect HTTP → HTTPS with 301
HSTS header Present, after you are sure HTTPS works everywhere

Online checkers such as SSL Labs (ssllabs.com/ssltest) grade a public configuration – use them only on your own domain.

Why this matters for security

HSTS (कठोर HTTPS धोरण) tells browsers never to use HTTP for your site again, which defeats SSL-stripping attacks on public Wi-Fi. Old protocols (SSLv3, TLS 1.0/1.1) have known weaknesses and are flagged by every vulnerability scanner.

Ravindra Bagale's Tip

If you set HSTS with includeSubDomains while some subdomain is still on HTTP, that subdomain stops working in browsers! Many students only find this out later. First check that all subdomains are on HTTPS, then turn on HSTS.

Practice task

Check your certificate dates with openssl, confirm TLS 1.1 is refused, add HSTS and verify the header with curl -sI.

Thodkyaat sangaycha tar

  • One IP can host many sites; the Host header picks the server block / virtual host.
  • Nginx: one server {} per site (conf.d/ on Amazon Linux; sites-available + symlink on Ubuntu) + a catch-all default_server returning 444.
  • Apache: one <VirtualHost> per site (conf.d/ on Amazon Linux; a2ensite on Ubuntu); the first loaded is the default.
  • Test without DNS: curl -H "Host: name" http://localhost or the hosts file.
  • Certbot: sudo certbot --nginx|--apache -d name --redirect; certbot renew --dry-run.
  • Harden TLS: only TLS 1.2/1.3; HSTS once HTTPS works everywhere.

Samjla ka? Part 6 sampla – tumhi aata real domain var HTTPS site chalavu shakta! Aata pudhe jaauya AWS S3 aani RDS kade.