0

For example: I host 4 websites on Ubuntu Server (10.20.30.40) with Nginx. Now, when somebody open browser and enters IP of my server how should I handle that kind of request. What admins mostly do with that ? I know ordinary users will never enter IP.

user3448600
  • 1,449
  • 2
  • 12
  • 12
  • Possible duplicate of [Setting Nginx to catch all unhandled vhosts](https://serverfault.com/questions/527156/setting-nginx-to-catch-all-unhandled-vhosts) – exeral May 09 '17 at 14:21
  • I'd say this is not a direct duplicate. The question linked already has a desired state. This is asking for best practices, instead. – Esa Jokinen May 09 '17 at 14:25

1 Answers1

3

When the server is shared among multiple domains, I've used to create a static page that handles all non-existing Host: headers, including the plain IP. The page may for example inform that this virtual host is not configured and possibly advertise the hosting service.

If the server is dedicated for hosting only one domain, I'd suggest a permanent redirect to the canonical hostname instead of serving the same site with all possible hostnames. That would be good for search engine optimization and TLS.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122