Disable IP Access

Setup www.example.com

a2dissite 000-default.conf
sudo systemctl reload apache2
cd /etc/apache2/sites-available/
sudo cp 000-default.conf www.example.com.conf

Edit www.example.com.conf

# Disable IP access
<VirtualHost *:80>
        # ServerName Server Name
        ServerName 192.168.1.216
        DocumentRoot /dev/null
        Redirect 403 /
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# www.example.com
<VirtualHost *:80>
        ServerName www.example.com
        DocumentRoot /var/www/html/www.example.com
         # Disable log files access
        <Files ~ ".log">
                Order allow,deny
                Deny from all
        </Files>
        ErrorLog /var/www/html/www.example.com/error.log
        CustomLog /var/www/html/www.example.com/access.log combined
</VirtualHost>

Enable site

a2ensite www.example.com.conf
sudo systemctl reload apache2