From b5e7290524de29bc396b39ae2d4c18b3dd5eef54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 28 Oct 2026 19:50:25 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20deploy:=20ferron.conf=20example,?= =?UTF-8?q?=20trusted=20proxies,=20share=20tokens=20out=20of=20access=20lo?= =?UTF-8?q?gs,=20tighter=20systemd=20unit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++--- config/in.example.toml | 1 + deploy/ferron.conf | 20 ++++++++++++++++++++ deploy/ferron.kdl | 6 ------ deploy/in.service | 9 +++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 deploy/ferron.conf delete mode 100644 deploy/ferron.kdl diff --git a/README.md b/README.md index c1cf51d..a070f24 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ user can read: | `database`, `data_dir` | Database file and data directory (blobs, staging, `in.key`, `in.lock`). The data directory is created with mode 0700. | | `listen` | Address to bind. Keep it on loopback and put the reverse proxy in front. | | `base_url` | Public origin with no trailing slash. An `https` origin turns on `Secure` cookies and HSTS. | -| `trusted_proxies` | Proxies whose `X-Forwarded-For` is believed. | +| `trusted_proxies` | Proxies whose `X-Forwarded-For` is believed. Behind Ferron on the same host, `["127.0.0.1/32"]`; left empty there, every visitor counts as the proxy. | | `[oidc]` | `issuer` (the `im` origin), `client_id` (the id `im` printed for this client), `client_secret_file`. | | `[storage]` | `backend = "local"` (default) or `"s3"` with `[storage.s3]`. | | `[backup]` | Optional. `dir`, `interval_hours`, `keep`, `healthcheck_url`. See *Backups*. | @@ -79,9 +79,10 @@ is the built-in default. A blank field on that page removes the page's value aga The scopes must include `directory.read`, which `in` uses to read the people directory; `im` does not grant it unless it is listed. -3. Put the reverse proxy in front (see `deploy/ferron.kdl`, an example for Ferron that proxies +3. Put the reverse proxy in front (see `deploy/ferron.conf`, an example for Ferron that proxies `https://in.example.com` to `127.0.0.1:7655`). Ferron must not buffer responses: the live update stream - depends on it. + depends on it. Set `trusted_proxies = ["127.0.0.1/32"]`, so the share-password throttle sees each visitor's + address, and keep `/s/` paths out of the access log: a share link's token is in its path. 4. Start the service: diff --git a/config/in.example.toml b/config/in.example.toml index d80badf..fbe363f 100644 --- a/config/in.example.toml +++ b/config/in.example.toml @@ -11,6 +11,7 @@ listen = "127.0.0.1:7655" # Public URL of this instance, with no trailing slash. An https URL turns on Secure cookies and HSTS. base_url = "http://127.0.0.1:7655" # Proxies whose X-Forwarded-For header is believed for client addresses. CIDR ranges or bare addresses. +# Behind Ferron on the same host, set ["127.0.0.1/32"]; left empty there, every visitor counts as 127.0.0.1. trusted_proxies = [] # Sign-in through im (OpenID Connect). Point issuer at the im instance you run (its origin, no diff --git a/deploy/ferron.conf b/deploy/ferron.conf new file mode 100644 index 0000000..4622954 --- /dev/null +++ b/deploy/ferron.conf @@ -0,0 +1,20 @@ +# Ferron reverse proxy for in. Same format as the forge and iz examples (ferron.conf, not KDL). +# Replace in.example.com with the public host name (base_url in /etc/in/in.toml must match it). +# A bare host block gets automatic TLS. +# +# The proxy sends X-Forwarded-For for the client. in reads that header only from peers listed in +# trusted_proxies; with Ferron on the same machine the peer is 127.0.0.1, so set +# trusted_proxies = ["127.0.0.1/32"] in in.toml. Left empty, every visitor counts as 127.0.0.1 and one +# visitor's failures throttle everyone. +# +# Buffering is off because the live update streams (server-sent events) must reach the browser +# as they are written. +# +# Keep /s/ (public share links) out of the access log: those paths carry tokens that grant access. +in.example.com { + buffer_request 0 + buffer_response 0 + proxy { + upstream http://127.0.0.1:7655 + } +} diff --git a/deploy/ferron.kdl b/deploy/ferron.kdl deleted file mode 100644 index eb7677a..0000000 --- a/deploy/ferron.kdl +++ /dev/null @@ -1,6 +0,0 @@ -// Example Ferron site for `in`. Ferron terminates TLS and forwards to the loopback listener of `in`. -// Check the directive names against the Ferron version you run; this file shows the shape, it has not been -// run against a live Ferron here. -in.example.com { - proxy http://127.0.0.1:7655 -} diff --git a/deploy/in.service b/deploy/in.service index 01d1471..a74545d 100644 --- a/deploy/in.service +++ b/deploy/in.service @@ -12,6 +12,8 @@ Group=in Environment=IN_CONFIG=/etc/in/in.toml ExecStart=/usr/local/bin/in serve WorkingDirectory=/var/lib/in +StateDirectory=in +StateDirectoryMode=0700 Restart=on-failure RestartSec=2 LimitNOFILE=65536 @@ -39,6 +41,13 @@ LockPersonality=yes MemoryDenyWriteExecute=yes SystemCallArchitectures=native SystemCallFilter=@system-service +SystemCallFilter=~@privileged +ProtectProc=invisible +ProcSubset=pid +RemoveIPC=yes +PrivateMounts=yes +KeyringMode=private +MemoryMax=2G CapabilityBoundingSet= AmbientCapabilities= UMask=0077