waf with the /go/waf Command

/go/waf uses the Cloudflare API to block IP addresses before they reach your server. It has two jobs: It uses the Cloudflare account ID and API token saved in GoAdmio's configuration. If you run it as a normal user, it re-runs itself with sudo. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Block an IP on one domain
/go/waf example.com 203.0.113.5

# Block an IP on all domains
/go/waf 203.0.113.5

Arguments

Form Domain IP Notes
/go/waf <ip> All The argument One argument is always read as an IP.
/go/waf all <ip> All The second argument Same result, written out.
/go/waf <domain> <ip> The first argument The second argument The domain needs a /home/<domain>/www folder.
/go/waf reset All None Deletes rules and filters. See Reset.

Arguments after the second are ignored.

IP rules

Rule Detail
Format A single IPv4 or IPv6 address.
Ranges Not supported. A range such as 203.0.113.0/24 is rejected by Cloudflare.
Validation None in the command. A wrong value is sent to Cloudflare, which answers with an error.

Examples

# Block one IP on one domain
/go/waf example.com 203.0.113.5

# Block one IP on every hosted domain
/go/waf 203.0.113.5

# The same, spelled out
/go/waf all 203.0.113.5

# Remove firewall rules and filters from every domain
/go/waf reset

# Check the recent runs
tail /var/log/go/waf.log

Output

Blocking

[1/3] Blocking IP 203.0.113.5 [example.com]...
{"result":{ ... },"success":true,"errors":[],"messages":[]}

The sample above is illustrative and shortened.

Part Meaning
[<n>/<total>] Blocking IP <ip> [<domain>]... Progress when blocking on all domains. With one domain the line is Blocking IP <ip> [<domain>]....
"success":true Cloudflare accepted the rule.
"success":false and an errors list The rule was refused. The message says why.

Reset

[1/3] Bulk Unbocking [example.com]...

Only the progress line is shown (the word is spelled Unbocking in the command’s output). Cloudflare’s answers are hidden, and the exit code is always 1.

Nothing printed

If you name a domain that has no /home/<domain>/www folder, the command prints nothing and does nothing.

See the full reference at /go/waf and the GoAdmio command index.

GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.

By:

Posted in:


Leave a Reply

Your email address will not be published. Required fields are marked *