Settings: path block list¶
Answer scanner paths (/.env, /wp-login.php, /.git/config) at the edge, with a 404 by default, before an access list, authentication or the upstream sees them. Off until you set it.
| Field | Type | Default | Notes |
|---|---|---|---|
pathBlock |
PathBlockMiddleware | unset | Optional. Unset blocks nothing. Applies to every proxy host that has not set pathBlock: off. |
pathBlock has exactly the shape and validation of a type: path-block middleware. The fields:
| Key | Type | Default | Required | Description |
|---|---|---|---|---|
extensions |
[]string | none | one of extensions, names, globs |
File extensions with the leading dot (.php, .env, .tar.gz). Matches when any path segment ends with one, so /a.php/extra is blocked too, and when a segment is the extension alone (/.env). At most 256 entries. |
names |
[]string | none | one of extensions, names, globs |
Whole path segments (.git, wp-admin, wp-login.php). Matches when any segment equals one, at any depth. At most 256 entries. |
globs |
[]string | none | one of extensions, names, globs |
path.Match patterns over the whole path, each starting with /, compared lower-cased, both as the path is and segment-folded without a trailing slash (/server-status also blocks /server-status/). A pattern that ends with / (other than / itself), has an empty segment, a segment ending in a dot or a space, or a control character is refused. * and ? never match /; a [...] class must be in lower case; there is no **. At most 64 entries, 128 bytes each, 2048 bytes in total. |
allowFrom |
[]string | none | no | Clients the list does not apply to: CIDRs, bare IPs and @<access-list> references. @name exempts a client only when the first rule of access list name that matches it is an allow rule (cidr or fetched source set) without paths: a client a deny rule above that allow rule matches stays blocked, and a path-scoped rule, the defaultAction and the geo rules exempt nobody. A disabled list exempts nobody. The list must exist: a settings write naming a missing list is always refused, and deleting a list this key names is refused too unless the stored state already fails the check (then it is accepted with a warning so it can be repaired). |
denyStatus |
int | 404 |
no | Status of a blocked request: 400 to 599 when set, unset or 0 means 404. |
denyWith |
string | error-page |
no | error-page renders the host's custom error page for the status when one exists; plain always writes the bare status text. |
Matching rules, limits (entries must be valid UTF-8; with globs, a path over 4096 bytes counts as listed), what the filter does not catch and the full field semantics are on PathBlockMiddleware.
Which hosts it covers¶
- Covered: every proxy host, including discovery-managed hosts, unless the host sets
pathBlock: off. - Not covered: the synthesized admin edge host (
settings.adminEdge). Atype: path-blockmiddleware named inadminEdge.middlewaresdoes apply to it. - Covered: a hand-written proxy host that fronts the admin panel (Reach the admin UI through gpm itself), like any other proxy host. A list that matches the panel's own paths can block it, so check the list against the panel first.
- Not covered: redirect hosts, parked hosts, stream hosts and the admin listener, which are not served by the proxy-host chain.
- ACME HTTP-01: gpm's own in-flight challenge tokens are answered before any host chain, so a list never affects them. Any other challenge path falls through to normal routing, so an upstream that runs its own ACME client is blocked if a list matches
/.well-known/acme-challenge/.... Keep.well-knownoff the list.
Per-host switch¶
pathBlock: inherit(the default, also when unset) applies the fleet list.pathBlock: offtakes that host out of the fleet list only. Atype: path-blockmiddleware the host or one of its locations references always applies.- On a discovery-managed host, set the switch on the discovery
templateor profile (Ingress discovery); a hand edit is rebuilt away at the next reconcile.
Behaviour¶
- Position. The fleet list runs outermost among the path-block steps, just inside the rate limit and ahead of access lists, the bouncer and authentication. See Request pipeline.
- Denial reason. Blocked requests are counted as
path-blockingpm_denials_total, in analytics and in the access log. - Scope of the filter. It matches path shape only: not content, and not a substitute for hardening the upstream.
- Check each host first. An application written in PHP needs
pathBlock: offor a list without.php. Keep.well-knownoff theextensions,namesandglobslists. - Open connections. A change to
settings.pathBlockcloses the open WebSocket and other upgraded connections of every host it covers at the reload, and so does a change to a host'spathBlockswitch. See Request pipeline. - A change applies at the next router build, like the other settings-level defaults.
# config/settings.yaml
pathBlock:
extensions: [".php", ".php5", ".phtml", ".asp", ".aspx", ".jsp", ".cgi", ".env", ".sql", ".bak", ".old", ".orig", ".swp", ".tar.gz", ".tgz"]
names: [".git", ".svn", ".hg", ".env", ".aws", ".ssh", ".DS_Store", ".htaccess", ".htpasswd", "wp-admin", "wp-includes", "wp-content", "wp-login.php", "xmlrpc.php", "phpmyadmin", "cgi-bin"]
globs: ["/server-status", "/server-info"]
allowFrom: [192.0.2.0/24] # for example the office network
denyStatus: 404
denyWith: error-page
For a walkthrough see Block scanner paths.