How do I block someone else from pointing to my Apache website?

Hi, I run my site on Linux VPS with a dedicated IP a few weeks ago. I found that the domain of another user points to my site.

Ex :: mydomain.com === server my site content otherdomain.com === also server my site content 

If I update or modify its receipt in another domain, too.

please help with any settings to prevent this.

after searching many forums, I found a virtual host based on the name of how to implement this in VPS Linux, please help me or any other solution to this problem, please help

I am also trying to see reverse IP lookup, my IP shows two domains of the other 1 - this is a bad domain indicating my server / IP, but it loads the contents of my site. How to stop this, please help

+5
source share
2 answers

If the domain does not belong to you, it does not suit you. Do not point it to your server, however you can point it to the surfer page using

VirtualHost <

Do this by doing the following: create a folder with the desired html / php file inside, indicating that the page does not exist or something else

then edit the VirtualHosts file, say using apache, this file will be located in the following directory: /etc/apache2/sites-available/ open the file named default and add the following code:

 <VirtualHost *:80> DocumentRoot /www/example2 ServerName www.example.org </VirtualHost> 
+3
source

I agree with @Azrael, but would like to expand it:

You can redirect your domain to a different page in each case, but what I would recommend doing, and what I do on most of my servers, prohibits all traffic, with the exception of traffic for the correct domain.

Apache 2.4 and later:

 <VirtualHost *:80> ServerName catchall <Location /> Require all denied </Location> </VirtualHost> <VirtualHost *:80> ServerName allowed.com <Location /> Require all granted </Location> </VirtualHost> 

Apache 2.2 and later:

 <VirtualHost *:80> ServerName catchall <Location /> Order allow,deny Deny from all </Location> </VirtualHost> <VirtualHost *:80> ServerName allowed.com <Location /> AllowOverride All Order allow,deny allow from all </Location> </VirtualHost> 

How it works, Apache uses ServerName to filter requests, however, any requests that do not match the VirtualHosts ServerNames names are sent to the first VirtualHost on the server, in this case the server_name in the first VirtualHost is β€œCatchall”, which will not match any requests, so as it is not a valid domain name, but instead, since it is the first VirtualHost, it serves all inappropriate domains. Then we use the location container to define allow or deny directives.

If you want to use the file system instead of specific url directives such as 'Allow overide all', you can use the directory container instead of the location in the following format:

 DocumentRoot /var/www/html <Directory "/var/www/html"> Require all granted Allow overide all </Directory> 
+9
source

Source: https://habr.com/ru/post/1200001/


All Articles