Published services → Reverse proxy

“A reverse proxy publishes a web service behind the appliance under a public name: the appliance’s proxy answers on 80 and 443, terminates TLS and forwards…

“A reverse proxy publishes a web service behind the appliance under a public name: the appliance’s proxy answers on 80 and 443, terminates TLS and forwards the request — unlike a port publication, the service never sees the internet directly.”

Before creating a proxy:

  • the public name (for example www.johnsmith.test) must point, in the public DNS, to an address of the appliance (for example 203.0.113.10);
  • for Let’s Encrypt, port 80 of the appliance must be reachable from the internet under that name;
  • the internal service must answer the appliance, for example http://192.168.10.40.

The list

The bar shows “Reverse proxy”, the count, the search and the “Reload” and “Add reverse proxy” buttons. Each row shows the proxy’s name, the public names, the internal service (“→ http://192.168.10.40”), “Enabled” or “Disabled” and the type of certificate. An amber note says what keeps an enabled proxy from working as configured:

  • “Not served by the proxy”: the site was not loaded (see the journal);
  • “Ports 80 and 443 are still closed in the running firewall: apply it from the header.”;
  • “Waiting for the Let’s Encrypt certificate”: meanwhile the certificate of the appliance’s CA is served.

If the nginx package is missing, the detail shows “The proxy service is not installed (package nginx): the proxies are saved but not served.”; without certbot, “The Let’s Encrypt client is not installed (package certbot): only the appliance CA’s certificate can be served.”

The detail of a reverse proxyThe detail of a reverse proxy
The detail of a reverse proxy

The fields

The form is divided into five blocks.

“Site”

  • “Name” — “What the proxy is called in this console.” Required, at most 64 bytes, different from the other proxies.
  • “Internal service” — “http(s)://host[:port] — an IPv4 address or a host name, no path. The appliance itself is refused.” Without a scheme, http applies. A name is resolved at every request, with the appliance’s DNS servers.
  • “The internal service’s certificate” (for an https:// service only) — how the appliance makes sure the service is really there: “Checked against the system’s authorities” (a certificate a public authority signed; a new proxy’s default), “Checked against a CA given here” (a self-signed service or one with an internal CA: paste the CA, or “Read from the service” offers it and you check its fingerprint with whoever runs the service before saving) or “Not checked” (the traffic stays encrypted but whoever stands on the way, or answers its DNS name, could read and change it; an amber note says so). “Name in the certificate” is for a certificate that names another host than the service’s, for example a service reached by its address. Proxies saved before this release stay “Not checked” until you change them; a proxy that asks for a CA and has none is not served.
  • “Public names” — “The names the proxy answers for (DNS must point them at the appliance). The first one names the certificate.” Type a name and add it with “Add name”; at most 20 names, no repeats. A name cannot belong to the console (its host name, its full name or the domain of its Let’s Encrypt certificate) nor to another proxy.
  • “Enabled” — on by default.

“Certificate”

  • “Certificate” — “Let’s Encrypt” (default) or “Signed by the appliance CA”. “Let’s Encrypt validates over port 80 (http-01) once the firewall runs with the proxy’s ports open; until then the appliance CA’s certificate is served.”
  • “Let’s Encrypt contact” — with Let’s Encrypt only, required. The address already used for the console’s certificate is proposed. It is given to Let’s Encrypt when the appliance’s ACME account is created; the warnings about a failed renewal come through the appliance’s mail relay (System → E-mail notifications).
  • “Served certificate” — only for a proxy already saved: “Let’s Encrypt — until date”, “Appliance CA — until date” or “Not served by the proxy”. An enabled Let’s Encrypt proxy has the “Request certificate” button (see below).

“Firewall”

  • The zones it answers on — one switch per zone, with the zone’s interfaces. “Ports 80 and 443 open on the interfaces of these zones. The page applies the firewall after a save that changes them — confirm it in the header.” For a new proxy the wan zone is proposed. At least one zone is required for an enabled proxy.
  • Below, for a saved proxy: “Ports 80 and 443 are open in the running firewall.” or, in amber, “Ports 80 and 443 are still closed in the running firewall: apply it from the header.”

“Options”

Field What it does Default
“Pass the Host header” “The service sees the public name; off, it sees its own address.” on
“WebSocket” “Upgrade passthrough and a one-hour read timeout.” off
“Maximum request body” “100m, 2g, 0 for no limit; empty = 1m, the default.” Raise it to upload large files empty (1 MB)
“Request buffering” “On, the proxy reads the whole request before passing it on; off, an upload streams to the service as it arrives.” on
“Read timeout (seconds)” how long the proxy waits for the service between two reads; 0 = 60 s (one hour with WebSocket), at most 86400 0
“Connect timeout (seconds)” how long the proxy waits to open the connection; 0 = 60 s, at most 75 0
“Limit each client” “Each client’s requests a second, past a burst; beyond them it gets 429. A browser asks many at once: keep the burst well above a page’s requests.” On, it shows “Requests a second” (1-10000, 20 proposed) and “Burst” (50 proposed) off

“Web application firewall (WAF)”

The WAF looks inside every request that reaches the site and refuses the ones carrying an attack: SQL injection, cross-site scripting, paths like ../../etc/passwd, shell commands, access to files like .env. It uses the OWASP Core Rule Set, which Argos carries and updates with its releases, plus CrowdSec’s rules against known vulnerabilities, which arrive every day. It works only with behavioural analysis on (Protection → Inspector); while it is off the fields are disabled and keep their value, and the block says “The WAF needs behavioural analysis: switch it on in Protection → Inspector.”. The same happens on an appliance whose behavioural analysis is still a version without a WAF (before 1.6): the block says “The WAF needs an updated behavioural analysis (CrowdSec 1.6 or later), which comes with the appliance’s updates: until then it stays as it is.”. A WAF left on while it cannot work (after a restore, for example) can always be set to “Off”, and never stops the proxy from being saved.

  • “Mode” — “Off”, “Detection only” or “Block”. “Detection only logs what would be blocked and lets it through, without bans; Block refuses it (403) and bans who insists.” A new proxy starts in “Block” (in “Off” while behavioural analysis is off); a proxy created before this release stays “Off” until you change it.
  • “Application profile” — “Generic” or “WordPress”. “WordPress leaves out the rules that refuse what WordPress normally sends (logins, the editor, comments).” Use it for every WordPress site: without it a password with unusual characters or a post about SQL can be blocked.
  • Below, the note: “Only the first 16 KB of a request’s body are inspected. While the WAF cannot answer, requests pass and Status says so. With the WAF on the whole request is read before it is passed on: request buffering off has no effect.”
  • “Rules left out” — the rules this proxy does not apply, each with who left it out and when. “Added from Events and diagnostics → WAF (“Exclude for this proxy” on a request).” The button beside a rule (“Take away the exclusion”) takes it off the form; it takes effect with “Save reverse proxy”.
The WAF block of a reverse proxyThe WAF block of a reverse proxy
The WAF block of a reverse proxy

What happens when you save

The “Effect of saving” panel says: “Updates the service when saved. Changes to zones or firewall enforcement may also require Apply in the header.” In practice:

  1. “Create reverse proxy” or “Save reverse proxy” writes the configuration and updates the site in the proxy at once (names, service, options and certificate apply straight away). If the proxy refuses the site, the proxy stays saved and you read “Saved, but the proxy did not take the site” followed by the reason.
  2. If the save changes the zones the proxies answer on, the page starts the firewall apply by itself (“Opening the ports: confirm the firewall apply in the header”): confirm within 60 seconds in the “Keep the new ruleset?” window.
  3. With Let’s Encrypt, if the ports are already open in the running firewall, the certificate is requested at once; otherwise after the apply is confirmed.
  4. If the proxy’s WAF changed (mode, profile, rules left out), the WAF’s new configuration takes effect at once, without applying the firewall. For a few seconds the WAF reloads its rules, and requests pass unchecked.

The web application firewall

What the visitor sees. A refused request gets a “Request blocked” page (in Italian or English, as the browser asks) with status 403, without saying which rule matched. The site never receives it. With “Detection only” the request reaches the site as if there were no WAF, and the event is logged all the same.

Bans. In “Block”, an address that insists (a few refused requests within seconds) is banned by behavioural analysis: for a while the appliance answers it no more, on any port. In “Detection only” nobody is banned. Private addresses and the far ends of the VPN tunnels are never banned.

The log. Every refused request, or one noticed in “Detection only”, appears in Events and diagnostics → WAF with the proxy, the address, the request and the rules that matched (see Events and diagnostics). The events are kept 7 days.

A false positive. If the WAF refuses something the site must accept, find the request in the log and press “Exclude for this proxy”: the rule no longer applies to that proxy, the other proxies still apply it. A real example: the tagline of a WordPress site with <html> in it trips rule 921130. The rules of the CRS’s own machinery (900…, 901…, 949…, 959…, 980…: the setup and the final decision) cannot be left out.

For a new service start in “Detection only”, use it for a few days as its users do, watch the log, leave out the rules that match good traffic, and only then switch to “Block”.

The limits. The WAF looks at the first 16 KB of a request’s body: an attack hidden further into an upload is not seen. If the WAF does not answer (behavioural analysis stopped, stuck, or reloading its rules) requests pass unchecked: a fault of the appliance must never take a customer’s site down. If behavioural analysis stays stuck after reloading its rules (it can happen while the WAF is under load), Argos restarts it by itself after a minute. Heavy requests (2 KB or more between address, headers and the start of the body: a long form, an upload, a very long search) go through the WAF in a queue: at most two per client at a time, and part of the WAF is always left to the light requests, which never wait. A heavy request waits for its turn 5 seconds at most: if its client meanwhile already had two being checked, it gets “Too many requests: try again in a few seconds.” (429), and behavioural analysis blocks the client that insists with requests that have a body (a form, an upload: a page’s files get nobody blocked); if instead the WAF was busy with those of many clients, it passes unchecked. So a single client no longer keeps the WAF busy for the others; from many sources at once it is a denial-of-service attack, and against that “Limit each client” helps. System status → Status says so: “In the last hour the WAF let 15 requests through uninspected: it stayed busy with others for longer than a request waits” and “In the last hour the WAF refused 229 requests from 6 clients that kept it busy; the behavioural protection bans those that insist”. If the WAF does not answer at all, Status says “The WAF is not inspecting: behavioural analysis does not answer, and the reverse proxies with the WAF on (1) let every request through uninspected”. If the running site serves a proxy with its WAF on without the WAF (the proxy refused the site that had it), Status says “Reverse proxies with the WAF on that the running site serves without it: 1. Their requests pass unchecked — save them again in Published services → Reverse proxy”. Behavioural analysis cannot be switched off in Protection → Inspector while a proxy has its WAF on.

The certificate

Let’s Encrypt. Until the certificate covers every name of the proxy, the proxy serves a certificate signed by the appliance’s CA, so the site still answers in HTTPS. The Let’s Encrypt certificate is requested:

  • on save, if the proxy’s ports are already open in the running firewall;
  • in the background after every confirmed firewall apply;
  • with the “Request certificate” button (“Asks Let’s Encrypt again now (up to three minutes). It is also asked for after every confirmed apply and by the daily pass.”). The button is disabled while there are unsaved changes or the ports are closed;
  • by the daily certificate pass, which also renews the certificates already issued and mails the problems (a failed renewal or issuance, a certificate about to expire).

The request is refused until the running firewall opens ports 80 and 443 in at least one of the proxy’s zones: “Ports 80 and 443 are closed in the running firewall: apply it first”. Having saved it is not enough. If you change the proxy’s names, the old certificate is deleted and a new one is requested with the current names.

If Let’s Encrypt does not succeed you read “Saved, but the certificate was not issued” with the reason or, from the button, “Saving the reverse proxy failed; error in the validation phase: check the public DNS names and that port 80 reaches the appliance.” Other reasons: “Another request to Let’s Encrypt is running: retry in a minute”, “Another certificate operation is running: retry in a minute”, “The Let’s Encrypt client is not installed (package certbot)”.

Signed by the appliance CA. The certificate is signed by the same private CA as the console’s self-signed certificate. Browsers accept it without warnings only on the computers that have imported that CA (you download it with “Download CA” in System → HTTPS certificate when the console uses the self-signed certificate). It suits internal services, not a public website.

Who reaches the proxy

The firewall opens ports 80 and 443 on all the zones of all the proxies together. This is why each proxy also checks which zone the client comes from: a client’s zone is the zone of the interface through which the appliance reaches it (the networks of the interfaces, of the static routes and of the tunnels; everything else is wan). A client of a zone the proxy does not list sees the connection closed without an answer. The Let’s Encrypt challenge on port 80, instead, stays reachable wherever port 80 is open.

To reach the site from the LAN too by its public name, also switch on the LAN zone in the “Firewall” block. If the public name resolves to an address the appliance holds, that is all it takes; if the appliance sits behind the provider’s router, add in DNS and DHCP → Local DNS a record pointing the name to the appliance’s LAN address (192.168.10.1).

The console never answers through a proxy

Every request that goes through a reverse proxy carries a header that marks it, and the console refuses any request that carries it. Even if the internal service were the appliance itself, by mistake or because a DNS resolution changed, the console would not answer a client on the internet as if it were local. For the same reason the “Internal service” cannot be the appliance (the loopback, localhost or one of its addresses).

A name no proxy knows, sent to 443, is answered by the console, which refuses the names that are not its own. A client connecting by IP address without a name reaches the console, which answers only from the zones where it is open.

Deleting a proxy

“Delete reverse proxy” asks: “Delete the reverse proxy site? Its certificates go with it, and its zones close ports 80 and 443 once the firewall is applied.” The site is removed from nginx at once; if the proxies’ zones change, the page starts the firewall apply, to be confirmed.

Error messages

Message Meaning
“Required” name, public names, internal service or contact missing
“At most 64 bytes” name too long
“Another proxy has this name”
“At most 20 names”
“Not a valid domain name”
“A name is listed twice”
“The console answers to this name (hostname, FQDN or Let’s Encrypt certificate: Settings)”
“Another proxy answers this name”
“Use http(s)://host[:port] with an IPv4 address or a host name”
“The appliance itself cannot be proxied”
“Not a valid email address” Let’s Encrypt contact
“Use digits with k, m or g (100m), or 0” maximum request body
“A whole number of seconds, 0-86400” / “A whole number of seconds, 0-75” timeouts
“Choose at least one zone”
“A zone is gone: pick the zones again”
“A port publication takes TCP 80 or 443 on one of these zones: switch it off or move it” conflict with an enabled publication
“The WAF needs behavioural analysis (Protection → Inspector)” the WAF on while behavioural analysis is off
“The WAF needs an updated behavioural analysis (CrowdSec 1.6 or later)” the WAF on where behavioural analysis has no WAF yet
“A rule left out is not a CRS rule number or a CrowdSec rule name”
“At most 100 rules left out”

For the technician The site is /etc/nginx/conf.d/argos-proxies.conf, checked with nginx -t before it replaces the previous one (which comes back if it is refused). Each proxy has a server on 80 (the ACME challenge from /.well-known/acme-challenge/, a 301 redirect to HTTPS) and one on 443 (TLS 1.2 and 1.3, HTTP/2). The client’s zone is decided by a geo block generated from the networks of interfaces, static routes and tunnels, regenerated when zones, interfaces, VLANs, routes and VPNs change; a client of a zone that is not listed receives 444. The service receives X-Real-IP, X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host and X-Argos-Reverse-Proxy: 1; the console answers 403 to any request carrying the latter. An https:// service receives the SNI (proxy_ssl_server_name on) and its certificate is checked as “The internal service’s certificate” asks (proxy_ssl_verify, proxy_ssl_trusted_certificate with the system bundle or with <TLS_DIR>/proxies/<id>.upstream-ca.pem, proxy_ssl_name). A name as the service is resolved at every request (resolver with the servers of /etc/resolv.conf), so a DNS that is not ready at boot does not stop nginx, and the console with it. In the firewall the rule is tcp dport { 80, 443 } accept comment "reverse proxy" in the zone_<name>_in chain, after forced DNS and before the services; in inspected zones it goes through Suricata. On the lan the console’s opening stays in the baseline rules: a proxy’s LAN clients do not go through the blocklist and the inspection on 80 and 443. Let’s Encrypt certificates: lineage argos-proxy-<id> with a deploy hook; the CA’s certificates in <TLS_DIR>/proxies/.

The WAF is CrowdSec’s AppSec. In the 443 server of a proxy with its WAF on, set $argos_waf "<id>;<mode>;<profile>" and an access_by_lua_block call Argos’s glue (/usr/lib/argos/scripts/waf/lua/argos_waf.lua, Debian’s nginx Lua module), loaded by /etc/nginx/conf.d/argos-waf.conf: it sends AppSec, on 127.0.0.1:7422, the X-Argos-Waf header, the key of the argos-waf bouncer (/etc/edon/argos-waf.key, 0600) and at most the first 16 KB of the body; it waits 100 ms for the connection, 100 ms for the send and 500 ms for the answer, and in any other case lets the request through (one line a minute in nginx’s error log). CrowdSec’s files are Argos’s by name: acquis.d/argos-waf.yaml, appsec-configs/argos-waf.yaml (per-proxy exclusions in pre_eval, “Detection only” in on_match), appsec-rules/argos-crs.yaml and argos-waf-proxies.yaml, contexts/argos-waf.yaml, the CRS 4.25 LTS copied to /var/lib/crowdsec/data/argos-crs/ with its argos-crs-*.data files. Every change goes through crowdsec -t before systemctl reload crowdsec; if it is refused, the previous files come back and Status says “The WAF’s configuration was not applied, the previous one stays: …”. The reload leaves AppSec silent for about 4 seconds. The events are CrowdSec’s alerts of kind waf (cscli alerts list --kind waf); config.yaml.local keeps 50 000 of them for 7 days.

LET’S TALK INFRASTRUCTURE

Control starts with a conversation.

Tell us about your infrastructure. Let’s start with what you actually need.

Talk to an engineer