Htaccess deny all allow from not working cause cloudflare keeps changing ip

I have an htaccess file that has a deny all allow from setting but i cant acces the webpage cause Cloudflare is changing my ip constantly, also the mod_Cloudflare is not an option since im on a shared hosting ,

How can i whitelist my ip or bypass Cloudflares ip changing thing so it shows my real ip when connecting

If you can put the part you need direct IP access on a separate subdomain you can switch that from :orange:-> :grey:. That will allow that part to go directly to your webserver while the rest is still proxied by Cloudflare. Alternatively you could allow Cloudflare servers through and create a firewall rule to keep others out.

hey when i make an .php page with the following it will show my real ip
<? echo ip=_SERVER[“HTTP_CF_CONNECTING_IP”];
if (!isset($ip)) {
ip = _SERVER[‘REMOTE_ADDR’];
}

is it possible to add that to .htaccess to determen the ip to allow

anyone?

Contact your host to ask whether they can enable mod_remoteip.

Please read OP

Wouldn’t that interfere with the shared hosting i have?

same issue as mod_Cloudflare?

I asked my hosting and as stated above i have a shared hosting ,
If they enable mod_Remoteip it will enable it for evreyone,

It sounds like you want to block access to a web page to everybody except yourself. I believe a Firewall Rule similar to this will work:

1 Like

Awesome that did the trick,

Is it possible to rederict the user to a custom page like page not found isntead of Cloudflare acces denied page?

Only Pro plans and above let you customize Cloudflare response pages.

Not asking to modify the page, i already have a custom page not found page, But i need the people who try to acces the page in the firewall rule to automatically redirect to my custom page not found page,

No, the Denied page is provided by Cloudflare, and that’s what the firewall show to a blocked user. The paid plans can completely replace that page with one of their own.

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