Ravindra BagaleCourses & study guides

13. Multiple Websites on One Server and HTTPS with Certbot

13.1 How Name-Based Virtual Hosting Works

Ekach IP, ekach port 80 – mag server la kasa kalte konti site dakhvaychi? Browser pratyek request madhe Host: header pathavto. Web server to header server_name / ServerName shi julavto.

 Browser: GET / HTTP/1.1  Host: site1.yourdomain.com  ─┐
 Browser: GET / HTTP/1.1  Host: site2.yourdomain.com  ─┼─► 203.0.113.10:80 ─► match Host
 Scanner: GET / HTTP/1.1  Host: 203.0.113.10          ─┘        │
                                                               ├─ site1 → /var/www/site1
                                                               ├─ site2 → /var/www/site2
                                                               └─ no match → default site

Why this matters for security

Scanners and bots usually connect by IP, not by name. If your default site is a real application, every internet scanner sees it. A catch-all default that returns nothing (Nginx return 444) hides your real sites from IP-based scanning and blocks Host-header tricks.

Ravindra Bagale's Tip

You created two sites and the same site shows on both – a common problem for students. The reason is that server_name doesn't match and the default site wins. Use sudo nginx -T | grep server_name or sudo apachectl -S to see which file answers for which name.

Practice task

Use curl -v http://example.com -o /dev/null and find the Host header your client sends.