Add secure X-Forwarded header forwarding with trusted proxy validation to fix SSL redirect loop#10
Merged
GrassBlock1 merged 9 commits intomasterfrom Feb 9, 2026
Conversation
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix infinite redirect issue with force_ssl enabled
Forward X-Forwarded-* headers to upstream to fix SSL redirect loop
Feb 9, 2026
Contributor
|
@copilot help to bump the version code please |
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Contributor
Author
GrassBlock1
approved these changes
Feb 9, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Rust-based Akkoma media proxy to forward X-Forwarded-* headers upstream to prevent infinite HTTPS redirect loops when Akkoma is configured with force_ssl: [rewrite_on: [:x_forwarded_proto]], alongside a version bump and documentation/release-note updates.
Changes:
- Forward
X-Forwarded-Proto,X-Forwarded-For, andX-Forwarded-Hostheaders from incoming requests to the upstream request. - Update docs and examples to document header forwarding and bump example
via_headerstrings. - Bump crate version to
0.1.1and add0.1.1release notes to the changelog.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/proxy.rs | Adds forwarding of X-Forwarded-* headers to upstream; includes formatting-only refactors elsewhere. |
| src/main.rs | Formatting-only changes to imports/logging and server start call. |
| src/image.rs | Formatting-only refactors (no functional change). |
| src/config.rs | Import ordering and formatting-only changes. |
| src/cache.rs | Formatting-only changes in implementation/tests. |
| config.example.toml | Bumps example via_header version to 0.1.1. |
| README.md | Documents X-Forwarded header forwarding; bumps example version string. |
| Cargo.toml | Version bump to 0.1.1. |
| Cargo.lock | Locks version bump to 0.1.1. |
| CHANGELOG.md | Adds 0.1.1 entry and updates compare links. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
…ding Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
Co-authored-by: GrassBlock1 <46253950+GrassBlock1@users.noreply.github.com>
GrassBlock1
approved these changes
Feb 9, 2026
Copilot
AI
changed the title
Forward X-Forwarded-* headers to upstream to fix SSL redirect loop
Add secure X-Forwarded header forwarding with trusted proxy validation to fix SSL redirect loop
Feb 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix infinite redirect loop with Akkoma's force_ssl configuration
Problem
When Akkoma has
force_ssl: [rewrite_on: [:x_forwarded_proto]]enabled, it checks theX-Forwarded-Protoheader to determine if the request is coming via HTTPS. If not set tohttps, Akkoma redirects to HTTPS. The proxy currently doesn't forward this header to upstream, causing Akkoma to always redirect, creating an infinite loop.Solution
Implemented secure, opt-in X-Forwarded header forwarding with trusted proxy validation to fix the redirect loop while preventing header spoofing attacks.
Changes Made
1. Security-First Configuration (
src/config.rs)forward_headers_enabledflag (default:false) - must be explicitly enabledtrusted_proxieslist for IP/CIDR validation2. Trusted Proxy Validation (
src/proxy.rs)ipnetworkcrate to validate client IPs against trusted proxy listis_trusted_proxy()function for IP validationapply_forwarded_headers()function implementing security policyproxy_handlerto extract client IP viaConnectInfo3. Server Infrastructure (
src/main.rs)ConnectInfolayer to enable client IP extractioninto_make_service_with_connect_info::<SocketAddr>()4. Dependencies (
Cargo.toml)ipnetwork = "0.20"for IP/CIDR parsing and validation5. Comprehensive Testing
6. Documentation
Security Improvements
Breaking Changes
None - This is a backward-compatible change. The feature is disabled by default, maintaining existing behavior.
Migration Guide
To enable X-Forwarded header forwarding:
forward_headers_enabled = truein your configtrusted_proxieswith your reverse proxy IPs/CIDRsExample for nginx on localhost:
Version
Bumped to 0.1.1 with full release notes in CHANGELOG.md
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.