From 55622e1ca35ea3b38edd7a8c999adf48121ebd1e Mon Sep 17 00:00:00 2001 From: John Coffey Date: Wed, 18 Nov 2026 19:46:21 -0700 Subject: [PATCH] Server: count clients by the address the proxies pass on INBUXA_HTTP_USE_FORWARDED=true on every server pod, so the server's limits and bans for failed sign-ins and anonymous requests count each client, not the ingress or the webmail. server.trustedProxies lists the proxies when the pod network isn't a private range. Older servers ignore the variable. --- CHANGELOG.md | 6 ++++++ charts/inbuxa/ci/everything-values.yaml | 1 + .../inbuxa/templates/server/deployment.yaml | 9 +++++++++ charts/inbuxa/tests/server_test.yaml | 20 +++++++++++++++++++ charts/inbuxa/values.schema.json | 6 ++++++ charts/inbuxa/values.yaml | 8 ++++++++ 6 files changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a45e917..8048071 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,12 @@ runs, pinned by digest. clients. - `routes`: the server's, the webmail's and the console's public addresses, each by host name, as Gateway API HTTPRoutes or one Ingress. +- The server counts clients by the address the ingress or gateway and the + webmail pass on (`INBUXA_HTTP_USE_FORWARDED`), so failed sign-ins and + anonymous requests aren't charged to the proxy: without it, enough wrong + passwords between all users would ban the ingress for everyone. + `server.trustedProxies` lists the proxies when the pod network isn't a + private range. Needs server 27.1-rc.32; older servers ignore it. - `networkPolicy`, on by default: every pod starts from deny all, in and out, and gets only what it needs. The server takes mail on its listeners from anywhere and connects anywhere; `networkPolicy.httpFrom` and diff --git a/charts/inbuxa/ci/everything-values.yaml b/charts/inbuxa/ci/everything-values.yaml index 3054075..ca71e68 100644 --- a/charts/inbuxa/ci/everything-values.yaml +++ b/charts/inbuxa/ci/everything-values.yaml @@ -19,6 +19,7 @@ server: - secretName: inbuxa-s3 items: [{key: secret-key, path: s3-secret-key}] publicUrl: https://mail.example.org + trustedProxies: [10.0.0.0/8, 100.64.0.0/10] listeners: pop3s: 995 groups: diff --git a/charts/inbuxa/templates/server/deployment.yaml b/charts/inbuxa/templates/server/deployment.yaml index 6b1a3b4..43ed7e7 100644 --- a/charts/inbuxa/templates/server/deployment.yaml +++ b/charts/inbuxa/templates/server/deployment.yaml @@ -144,6 +144,15 @@ spec: {{- end }} - name: INBUXA_LISTENER_PORTS value: {{ include "inbuxa.server.listenerPorts" $root | quote }} + # Reached only through the ingress or gateway and the webmail: + # count each client by the address they pass on, so failed + # sign-ins and anonymous requests aren't charged to the proxy + - name: INBUXA_HTTP_USE_FORWARDED + value: "true" + {{- with $server.trustedProxies }} + - name: INBUXA_HTTP_TRUSTED_PROXIES + value: {{ join "," . | quote }} + {{- end }} {{- /* The front ends, registered as OAuth clients on every start */}} {{- with $root.Values.webmail }} {{- if .enabled }} diff --git a/charts/inbuxa/tests/server_test.yaml b/charts/inbuxa/tests/server_test.yaml index 73d26c7..d32eef4 100644 --- a/charts/inbuxa/tests/server_test.yaml +++ b/charts/inbuxa/tests/server_test.yaml @@ -236,3 +236,23 @@ tests: template: server/deployment.yaml asserts: - failedTemplate: {} + + - it: counts clients by the address the proxies pass on + template: server/deployment.yaml + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_HTTP_USE_FORWARDED, value: "true"} + - notContains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_HTTP_TRUSTED_PROXIES} + any: true + + - it: trusts the proxies it's given instead of the private ranges + template: server/deployment.yaml + set: + server.trustedProxies: [100.64.0.0/10, 10.0.0.0/8] + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_HTTP_TRUSTED_PROXIES, value: "100.64.0.0/10,10.0.0.0/8"} diff --git a/charts/inbuxa/values.schema.json b/charts/inbuxa/values.schema.json index b6fab13..9db79c9 100644 --- a/charts/inbuxa/values.schema.json +++ b/charts/inbuxa/values.schema.json @@ -263,6 +263,12 @@ "type": "string", "pattern": "^(https?://[^/\\s]+)?$" }, + "trustedProxies": { + "type": "array", + "items": { + "type": "string" + } + }, "listeners": { "type": "object", "additionalProperties": false, diff --git a/charts/inbuxa/values.yaml b/charts/inbuxa/values.yaml index 497dadf..f07f731 100644 --- a/charts/inbuxa/values.yaml +++ b/charts/inbuxa/values.yaml @@ -80,6 +80,14 @@ server: # pages and OAuth metadata name it. publicUrl: "" + # The proxies whose X-Forwarded-For the server believes, as CIDRs: the + # ingress or gateway, and the webmail. The server reads the header so that + # its limits and bans for failed sign-ins count each client, not the proxy. + # Empty: loopback and the private ranges, which covers pods on most + # clusters. List your pod network here if it isn't private (100.64.0.0/10, + # say). + trustedProxies: [] + # The port in the pod of each listener a new store gets, which is what # the Services send traffic to. 0 leaves that listener out. The pods may # listen below 1024 without any privilege: they set the namespaced sysctl -- 2.54.0