V
V
Vladislav2019-10-04 15:14:08
cloudflare
Vladislav, 2019-10-04 15:14:08

.htaccess cloudflare?

How to allow access only to certain .htaccess ips, when you access the site through cloudflare, it sees the cloudflare ip and does not see the real ip, so access can be opened either to everyone or closed to everyone.
Site on ukraine hosting

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-10-04
@Vladyslawx

Cloudflare passes the client's ip in the CF-Connecting-IP header.
If Apache version >= 2.4

Require expr "req_novary('CF-Connecting-IP') -ipmatch '1.2.3.0/24' "
Require expr "req_novary('CF-Connecting-IP') -ipmatch '7.7.7.7' "

In older versions, mod_rewrite will help.
RewriteEngine On

RewriteCond %{HTTP:CF-Connecting-IP} !^1\.2\.3
RewriteCond %{HTTP:CF-Connecting-IP} !=7.7.7.7
RewriteRule ^ - [R=403,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question