If hosting only one site on a server with no control panel, is there any advantage to using a virtual host?

server asked:

The site is hosted on AWS and the website is dropped into the var www html directory. Is there any advantage to setting up a virtual host considering this will be the only domain on the server?

My answer:

The main advantage of placing your web site in a virtual host is that the default (virtual) host, which Apache’s syntax doesn’t place inside any <VirtualHost> block, will catch requests for any site other than yours. This includes things like localhost (if you didn’t make a virtual host for it), the system’s IP address, no host specified, etc. Nearly all of such traffic is garbage or potentially malicious, and by default they get a 403, 404 and/or a tiny test page (depending on your distribution), and never hit your web application.

These days, with most web sites moving to HTTPS, it’s also a good idea to enable the default HTTPS virtual host (which the default Apache config usually has commented out) with a self-signed certificate such as the snakeoil.crt that Debian systems create. This will prevent such garbage or malicious HTTPS traffic as described above from reaching your web app.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.