underattack with the /go/underattack Command

Cloudflare's Under Attack Mode is an emergency setting for a site that is being flooded with traffic. Every visitor first sees a short browser check before they reach the site, which stops most bots. /go/underattack turns it on for one domain or for all domains. For each domain it: Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.

Quick start

# Turn on Under Attack Mode for one domain
/go/underattack example.com

# Turn it back down to High
/go/underattack example.com off

Options

Argument Required Default Notes
<domain> or all No — A hosting account’s domain (/home/<domain>/www must exist), or all.
[level] No Under Attack See the table below.

How the level word is read:

You pass Level set in Cloudflare
Nothing, or any other word (true, on, under_attack, and so on) under_attack
medium medium
high, off, no, none, false, or 0 high

[!NOTE]
"Off" doesn’t mean the lowest level. It sets the level to High. The command can’t set Low or Off.

Examples

# Turn on Under Attack Mode for one domain
/go/underattack example.com

# Turn on Under Attack Mode everywhere
/go/underattack all

# Go back to High (this does not restore the old level)
/go/underattack example.com off

# Use Medium
/go/underattack example.com medium

# Switch off the domains that have been under attack for an hour or more
/go/underattack

# Stop Under Attack Mode being enabled for one domain by this command
touch /home/example.com/www/underattack

Output

For each domain, the command prints a line, then the answer Cloudflare returned for the security level change:

example.com (under_attack)...
{"result":{"id":"security_level","value":"under_attack", ... },"success":true,"errors":[],"messages":[]}

With all, each line starts with a counter, such as [3/12] example.com (under_attack)....

Look for "success":true. When it is false, the errors list says why.

When the no-argument run switches a domain off, it prints:

Turn Off Under Attack Mode: example.com

Outcome What you get
Level changed The line and Cloudflare’s answer.
Domain folder missing No output. Nothing is changed.
Domain opted out Domain <domain> under attack mode disabled. To enable under attack mode remove file /home/<domain>/www/underattack
No-argument run Exit status 1.

Every run is logged to /var/log/go/underattack.log with a timestamp and the arguments used. Automatic switch-offs are logged there as well.

See the full reference at /go/underattack 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 *