How to stop spam domains pointing to your server I.P

I recently faced a problem.

Some domains which are not owned by me were showing the same content as my main website.

They were using reverse proxy and pointing to server I.P.

How I resolved this issue?

I was using NGINX, so first of all, I moved to Apache.

Login to your Server via SSH and type the following command:

sudo nano /etc/apache2/sites-available/ 

Now a file editor will open, paste the following code in it and replace with your own primary domain.

<VirtualHost *:80>       

        DocumentRoot /var/www/

        <Directory "/var/www/">
             AllowOverride All

        ErrorLog ${APACHE_LOG_DIR}/
        CustomLog ${APACHE_LOG_DIR}/ combined

This will create a virtual host in your Apache server config so, whenever some domain point to your server it won’t load your website. Instead it will show Apache server page.

You can also do some changes like create a 404.html page with a warning message that this site doesn’t belong to current domain please visit

For more information:

1 Like

For Apache, NGINX or using Cloudflare - This is how it can be done.