0

I am getting lot of unwanted web site traffic to my WordPress web site. It is apache web server on Ubuntu 20.04.

Is there any way to block them.

Please refer the screen shot.log example

2
  • Your web server will respond to every http request, regardless if that request is for valid and existing or invalid and non-existent content. That is unavoidable. ... You can make your logs cleaner and ensure that only requests using the name of your website will show content from your site by setting up Name Based Virtual hosting. You do that by setting up at least two default VirtualHost entries, one (or more) for your actual site(s) and a default virtual host that will respond to all requests that don't include your site name(s), such as requests made to your IP-address.
    – Bob
    May 31, 2021 at 10:24
  • Thanks @Bob, Is it possible to share example virtual host configuration files?
    – Support
    May 31, 2021 at 14:06

1 Answer 1

0

Your web server will respond to every http request, regardless if that request is for valid and existing or invalid and non-existent content. That is unavoidable. ...

One approach to make your logs cleaner and to ensure that only requests using the name of your website will show content from your site by setting up Name Based Virtual hosting.

You do that by setting up at least two VirtualHost entries, one (or more) for your actual site(s) and a default virtual host that will respond to all requests that don't include your site name(s), such as requests made to your IP-address

From https://httpd.apache.org/docs/2.4/vhosts/examples.html

<VirtualHost *:80>
    ServerName default
    DocumentRoot "/www/default"
</VirtualHost>

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

    # Other directives here 
</VirtualHost>
# additional VirtualHost blocks

You can then use some tricks in the first virtual host declaration to always return an 410 error code rather than (trying to serve) content from an alternate document root by using something along the lines of

<VirtualHost *:80>
    ServerName default
    # Don't log requests 
    CustomLog /dev/null common
    ErrorLog  /dev/null
    # Forces the server to return a 410 Gone status on all requests
    RewriteEngine On
    RewriteRule .* - [G]
</VirtualHost>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.