Ravindra BagaleCourses & study guides मराठी Track your progress

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.

Extended teaching notes

Why this lesson matters

Cryptography fails when people invent it. Use standard libraries, modern algorithms (AES-GCM, TLS 1.2+, bcrypt/argon2) and protect keys in a KMS or secrets manager.

Where crypto shows up

[('Passwords', 'bcrypt/argon2/PBKDF2 via the framework hasher — never plain MD5/SHA1.'), ('TLS', "Terminate on ALB/nginx with ACM/Let's Encrypt; redirect HTTP to HTTPS."), ('JWT / API tokens', 'Short lifetime, rotate signing keys, store secrets outside Git.'), ('Disk / S3', 'Provider or customer-managed keys; least privilege on decrypt.')]

Mini case study

Suppose we are on a purple-team exercise for an Indian mid-size company (sample data). Red notes a technique from this lesson against a lab clone. Blue must show the control that stops it, the log that would have fired, and the ticket that hardens production. That is the standard this course trains you for.

Defender's worksheet (do this today)

  1. Write the lesson title, date and the exact lab target you are allowed to use.
  2. List three owned systems (VMs, apps, or cloud accounts) where this lesson applies.
  3. Run one safe check from the lesson on a lab system only. Paste the command and output.
  4. Write a two-sentence fix you would give a teammate.
  5. Name one related public advisory (CERT-In, CISA, NVD, or a vendor bulletin) with its date.

Indian workplace (sample data)

Suppose we are a junior analyst at Infosys, TCS, Wipro or a fintech SOC in Bengaluru/Pune. Turn this lesson into one checklist item with an owner, a due date and a place to store evidence (ticket + screenshot).

Global practice

Compare your notes with OWASP, CIS Benchmarks, NIST CSF/IR guidance or a cloud Well-Architected security question. Write five lines on what overlaps.

Everyday analogy

Explain the risk and the fix to a family member without jargon. If they can repeat the warning, you understand it well enough to teach juniors.

Key terms

  • Control: a safeguard (patch, config, process, detection).
  • Finding: a weakness backed by evidence.
  • Remediation: the fix plus how you verified it.
  • Scope: systems you have written permission to touch.
  • Least privilege: only the access the task needs.
  • Defence in depth: several layers so one failure does not end the story.

Common mistakes

  • Skipping written permission "just for a quick scan".
  • Practising on hostel, office or public targets without authorisation.
  • Collecting tool output without writing the fix.
  • Copying attack steps onto production to "verify". Defenders verify with versions, configs and patches.
  • Publishing screenshots that contain secrets, cookies or internal hostnames.

Recap

  • Evidence, fix, owner, date.
  • Own lab only.
  • Fix > spectacle.