block proxy servers to access wordpress

WordPress is always very target for hackers. Hackers always use the proxy servers to access the wordpress websites. Hackers attack the wordpress sites using the proxy IP addresses and servers. Here Using small trick you can prevent the proxy server attack. This is very easy trick which can be used in every wordpress project.

block proxy servers to access wordpress

All proxy visits are not bad requests so First check the site access logs. If you are thinking Your site attacked by Hackers and proxy servers then only use the following code.

 

You just need to add following code into your .htaccess file. You can open your .htaccess apache configuration file from wordpress root folder.

# BLOCK PROXY VISITS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:VIA}                 !^$ [OR]
RewriteCond %{HTTP:FORWARDED}           !^$ [OR]
RewriteCond %{HTTP:USERAGENT_VIA}       !^$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR}     !^$ [OR]
RewriteCond %{HTTP:PROXY_CONNECTION}    !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}   !^$ [OR]
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
RewriteCond %{HTTP:HTTP_CLIENT_IP}      !^$
RewriteRule .* - [F]
</IfModule>

After adding above code you must check your wordpress site. Check the your every pages of your site. Check your sites pages on atleast on three PCs so you will sure about your site and above code.

Open your header.php file which you find in your wordpress theme folder.

Take backup header.php file first.

<?php if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)) die("Proxy access not allowed"); ?>

Put above code in header.php file and check your site is working fine. There are so many articles written on same topic so you can check those also before making any changes.

block proxy servers to access wordpress
block proxy servers to access wordpress