How can I block all User Agents and only allow mine? Maybe with Cookies?

Thinking about security i use the Chrome extension: User-Agent Switcher for Chrome - Chrome Web Store

With it I can add custom values to the User Agent, in my case, for example, every time I access the Panel, it automatically inserts values to the User Agent, being:

user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36 {CUSTOM VALUE}

In CloudFlare, using WAF rules, I configure it like this:

Hostname, contains {panel address} & Does not contain {CUSTOM VALUE} in user agent? BLOCK!

It’s working fine, but I’d like to use this same rule without Cloudflare, right in the CSF Firewall.
Because if you put the ip directly, Cloudflare rules are not applied.

How can I achieve this my friend?

By doing this, am I preventing some important connection? Does it interfere with services like Updates or even Backup to Google Drive?

Note: This also works with Cookie, manually editing via F12, for Cookie is more easier set the Rule in Server?

I have read somewhere and if im not mistaken modsecurity suit your need.

1 Like

I think I could also deny all direct requests to the IP, forcing everyone to go through Cloudflare, is that possible?

But I need to make SSH 22 accessible to Putty

I think I found a way, thanks!

But I need these rules to only work in the administrative parts, not for all sites…