How to ban people on wordpress + cloudflare when we don't know their IP?

#1

I have commentators which i want to ban from my site. How to do that when im using cloudflare?

0 Likes

#2

you need some way to identify them

0 Likes

#3

How when they have cloudflare IP?

0 Likes

#4

see if this help you https://support.cloudflare.com/hc/en-us/articles/227634427-Using-Cloudflare-with-WordPress

0 Likes

#5

This won’t help. Even when i disable cloudflare then i don’t see my commenters IPs.

But if i would have IP then i can block it by rule in cloudflare firewall?

0 Likes

#6

Use Wordfence, It can pull Visitor IP addresses from the headers and you can manually block them in Wordfence’s firewall.

0 Likes

#7

Then i uderstand cloudflare can’t block these people?

0 Likes

#8

you can block ip in cloudflare via firewall rules or ip access rules

0 Likes

#9

Only if you know their IP address.

0 Likes

#10

Ok and only way to find their IP is to disable cloudflare? We can’t disable only IP masking? Because actually all of commenters have one IP from cloudflare 162xxxxxx

0 Likes

#11

Here’s what you need to configure on your server to restore visitor IP addresses:
https://support.cloudflare.com/hc/en-us/sections/200805497-Restoring-Visitor-IPs

1 Like

#12

I don’t see fix for Wordpress.

0 Likes

#13

That’s a server level configuration.

It sounds like you want to block commenters by IP address, but your server does not display original visitor IP address because they are coming through Cloudflare. Your host needs to fix this on the server.

0 Likes

#14

My host is using apache but here it says that cloudflare don’t support this?

0 Likes

#15

I’ve not tried this, but add the following lines to your theme’s functions.php file:

if ( isset( $_SERVER["HTTP_CF_CONNECTING_IP"] ) ) {
 $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}

If that’s successful, then your WordPress dashboard’s Comments section should show the correct IP address of the commenters.

Let me know if that works.

0 Likes

#16

Hi. Your code is working. Thank you! Why not implement it on cloudflare automaticcly?

0 Likes

#17

This has to be done at the source (your server/site).

0 Likes

#18

Instead of editing wordpress code, proper way for apache to retrieve real visitor ip passed on from cloudflare headers is to use apache 2.4’s mod_remoteip which is native to apache so no need for mod_cloudflare. Your web host should know how to configure and setup mod_remoteip for you https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html

0 Likes

#19

I believe remoteip also requires a list of Cloudflare IP addresses, but the same way the NGINX configuration works. Not only that, but hosts generally aren’t fond of changing their server configuration files per user requests.

Thankfully, the WordPress mod is quick and easy…and one I hadn’t heard of before now.

0 Likes

closed #20

This topic was automatically closed after 30 days. New replies are no longer allowed.

0 Likes