Skip to content

fix: make Arcane reverse-proxy aware to resolve connection issues#2717

Merged
kmendell merged 1 commit into
mainfrom
fix/rp-issues
May 24, 2026
Merged

fix: make Arcane reverse-proxy aware to resolve connection issues#2717
kmendell merged 1 commit into
mainfrom
fix/rp-issues

Conversation

@kmendell
Copy link
Copy Markdown
Member

@kmendell kmendell commented May 23, 2026

Checklist

  • This PR is not opened from my fork’s main branch

What This PR Implements

Fixes: #2661

Changes Made

Testing Done

  • Development environment started: ./scripts/development/dev.sh start
  • Frontend verified at http://localhost:3000
  • Backend verified at http://localhost:3552
  • Manual testing completed (describe):
  • No linting errors (e.g., just lint all)
  • Backend tests pass: just test backend

AI Tool Used (if applicable)

AI Tool:
Assistance Level:
What AI helped with:
I reviewed and edited all AI-generated output:
I ran all required tests and manually verified changes:

Additional Context

Disclaimer Greptiles Reviews use AI, make sure to check over its work.

To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike

To have Greptile Re-Review the changes, mention greptileai.

Greptile Summary

This PR makes Arcane reverse-proxy aware by introducing a TRUSTED_PROXIES-gated middleware that propagates the HTTPS scheme decision via request context so cookie names (__Host-token vs token), Secure flags, and clear directives all round-trip correctly through an HTTPS reverse proxy. It also adds a WebSocket ping/pong heartbeat to prevent idle connections from being silently dropped by upstream proxies.

  • Cookie scheme detection is moved from raw X-Forwarded-Proto inspection to a context key populated by secureCookieContextMiddlewareInternal, which checks that the direct TCP peer falls within TRUSTED_PROXIES before trusting the header — untrusted clients cannot spoof the flag.
  • Auto-proxy defaults: when LISTEN is bound to an explicit loopback IP literal, TRUSTED_PROXIES is auto-set to loopback CIDRs so the typical Caddy/Nginx/Traefik setup works without manual configuration.
  • WebSocket heartbeat: forwardAgentToClient now sends a ping every 54 s and closes the stream if no pong arrives within 60 s, with properly scoped write deadlines (1 s for ping frames, 10 s for data frames).

Confidence Score: 5/5

Safe to merge; the trust-gating logic correctly validates the TCP peer before honoring X-Forwarded-Proto, and both cookie set and clear paths now use consistent names for the secure context.

The core security property — that untrusted clients cannot force __Host-token / Secure cookies by forging X-Forwarded-Proto — is enforced at the middleware layer against req.RemoteAddr, which cannot be spoofed by application-level headers. Cookie name selection and clear directives are now symmetric. The only finding is a naming-convention nit on the new applyProxyDefaults helper.

No files require special attention beyond the minor naming convention issue in backend/internal/config/config.go.

Fix All in Codex Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
backend/internal/config/config.go:136
The new `applyProxyDefaults` function is unexported but lacks the `Internal` suffix required by the project's naming rule for private helpers. All other new private helpers in this PR follow the convention (`parseTrustedProxyCIDRsInternal`, `secureCookieContextMiddlewareInternal`, `remoteAddrInTrustedProxiesInternal`, `buildClearTokenCookieStringInternal`).

```suggestion
func applyProxyDefaultsInternal(cfg *Config) {
```

Reviews (3): Last reviewed commit: "fix: make Arcane reverse-proxy aware to ..." | Re-trigger Greptile

Context used:

  • Rule used - What: All unexported functions must have the "Inte... (source)

@kmendell kmendell marked this pull request as ready for review May 23, 2026 18:55
Copy link
Copy Markdown
Member Author

kmendell commented May 23, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@getarcaneappbot
Copy link
Copy Markdown
Contributor

getarcaneappbot commented May 23, 2026

Container images for this PR have been built successfully!

  • Manager: ghcr.io/getarcaneapp/manager:pr-2717
  • Agent: ghcr.io/getarcaneapp/agent:pr-2717

Built from commit 0e5c58c

Comment thread backend/pkg/utils/cookie/cookie_util.go Outdated
Comment thread backend/pkg/utils/cookie/cookie_util.go Outdated
Comment thread backend/internal/config/config.go Outdated
@kmendell kmendell force-pushed the fix/rp-issues branch 5 times, most recently from 474d33d to 2db7299 Compare May 23, 2026 22:26
@kmendell kmendell merged commit 7d72bb1 into main May 24, 2026
26 checks passed
@kmendell kmendell deleted the fix/rp-issues branch May 24, 2026 03:30
github-actions Bot added a commit to ShobuPrime/home-assistant-apps that referenced this pull request May 26, 2026
## Arcane Docker Manager Update

This automated PR updates Arcane from `1.19.4` to `1.19.5`.

### Changelog


### Bug fixes

* improve environment proxy error handling ([#2649](getarcaneapp/arcane#2649) by `kmendell`)
* align local BuildKit load/push exporter ([#2650](getarcaneapp/arcane#2650) by `kmendell`)
* PUID and PGID being set on project subfolder on every startup ([#2656](getarcaneapp/arcane#2656) by `kmendell`)
* system upgrade doesnt support non unix socket docker hosts ([#2651](getarcaneapp/arcane#2651) by `kmendell`)
* resizing window discards edits in compose editors ([#2719](getarcaneapp/arcane#2719) by `kmendell`)
* only validate project name if it has changed ([#2720](getarcaneapp/arcane#2720) by `kmendell`)
* make Arcane reverse-proxy aware to resolve connection issues ([#2717](getarcaneapp/arcane#2717) by `kmendell`)
* tolerate undefined typed env vars in GitOps sync ([#2721](https://github.com/getarcaneapp/arcane/pu

### Changes

- Updated `config.yaml` version
- Updated `build.yaml` ARCANE_VERSION
- Updated `Dockerfile` ARCANE_VERSION
- Updated documentation files
- Updated CHANGELOG.md

### Release Notes

Full release notes: https://github.com/getarcaneapp/arcane/releases/tag/v1.19.5

---

This PR was automatically generated by the Update Arcane workflow

Auto-merged by GitHub Actions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Bug: Connection issues when running behind Reverse Proxy

2 participants