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/example.com.conf 

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

<VirtualHost *:80>       
        ServerName www.example.com
        ServerAlias example.com

        DocumentRoot /var/www/example.com

        
        <Directory "/var/www/example.com">
             AllowOverride All
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/example.com.error.log
        CustomLog ${APACHE_LOG_DIR}/example.com.access.log combined
</VirtualHost>

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 xyz.com

For more information: http://httpd.apache.org/docs/current/vhosts/name-based.html

1 Like

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