'Reverse proxy returned invalid status code' when trying to programmatically clear the HTTP cache

The reason nginx is rejecting the BAN and returning 405 is explained in this PR - would you be able to independently verify the solution and reply in the github issue or here if this helps you?

If you get a 405 from varnish, the reason should be a different one, and the requester IP not among the allowed purgers, see the varnish setup

Per default no proxyurl is defined, and as you point out, in a commandline context, the httpcache service is not present and the BAN request will always be executed (see getProxyUrl() fallback).

For nginx to then forward the BAN request to fastcgi, the proposed rewrite is a solution - and the request will go through if the origin IP is among the purge_allowed_ips (per default the ip v4/v6 loopback addresses).