cloudflare / Cloudflare-WordPress

A Cloudflare plugin for WordPress
https://www.cloudflare.com/wordpress/
BSD 3-Clause "New" or "Revised" License
216 stars 83 forks source link

Wordpress plugin gives "400 bad response" when enabling WAF #507

Closed Sageth closed 1 year ago

Sageth commented 1 year ago

Confirmation

WordPress version

6.1.1

Cloudflare-WordPress version

4.11.0

PHP version

8.2.4

Expected result

When I click on WAF to enable the settings in the Wordpress plugin, it enables or provides a reason on why it can't be enabled (or, if it can't be enabled due to a conflicting setting, it is not selectable).

Actual result

When I enable WAF, I get the error:

PHP message: [Cloudflare] ERROR: [CLIENT API] Array ( [type] => request [path] => https://api.cloudflare.com/client/v4/zones//settings/waf?action=cloudflare_proxy [timeout] => 30 [method] => PATCH [headers] => Array ( [Content-Type] => application/json [User-Agent] => wordpress/6.1.1; cloudflare-wordpress-plugin/4.11.0 [Authorization] => REDACTED )

[body] => {"value":"on"}

) ; PHP message: [Cloudflare] ERROR: [CLIENT API] Array ( [type] => response [reason] => Bad Request [code] => 400 )

Steps to reproduce

  1. Install cloudflare plugin (I use APO, unsure if requirement)
  2. Click settings
  3. Scroll down to "Web Application Firewall"
  4. Enable it
  5. See error that just says "bad request" in the bottom of the page alert. Log shows:
PHP message: [Cloudflare] ERROR: [CLIENT API] Array
(
    [type] => request
    [path] => https://api.cloudflare.com/client/v4/zones/<zone id>/settings/waf?action=cloudflare_proxy
    [timeout] => 30
    [method] => PATCH
    [headers] => Array
        (
            [Content-Type] => application/json
            [User-Agent] => wordpress/6.1.1; cloudflare-wordpress-plugin/4.11.0
            [Authorization] => REDACTED
        )

    [body] => {"value":"on"}
)
 ; PHP message: [Cloudflare] ERROR: [CLIENT API] Array
(
    [type] => response
    [reason] => Bad Request
    [code] => 400
)
 ; PHP message: [Cloudflare] ERROR: Bad Request" while reading response header from upstream, client: 2601:x:x:x::x, server: www.example.com, request: "PATCH /wp-admin/admin-ajax.php?action=cloudflare_proxy HTTP/2.0", upstream: "fastcgi://unix:/var/run/php-fcgi.pid:", host: "www.example.com", referrer: "https://www.example.com/wp-admin/options-general.php?page=cloudflare"

Additional factoids

No response

References

The following seem to have similar error messages. Unsure if same cause: https://github.com/cloudflare/Cloudflare-WordPress/issues/506 https://github.com/cloudflare/Cloudflare-WordPress/issues/481

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.