Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Replace deprecated `httputil.ReverseProxy.Director` with `Rewrite` in `pkg/proxy/server.go`; `Director` is deprecated since Go 1.26 (SA1019); `Rewrite` achieves the same Host-preservation behaviour and has been available since Go 1.20.

## [1.3.0] - 2026-03-08

### Added
Expand Down
12 changes: 5 additions & 7 deletions pkg/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ func StartServer(opts ServerOptions, d detector.Detector) error {
Level: slog.LevelInfo,
}))

proxy := httputil.NewSingleHostReverseProxy(target)

// Preserve the original Host header
originalDirector := proxy.Director
proxy.Director = func(req *http.Request) {
originalDirector(req)
req.Host = target.Host
proxy := &httputil.ReverseProxy{
Rewrite: func(r *httputil.ProxyRequest) {
r.SetURL(target)
r.Out.Host = target.Host
Comment on lines +39 to +41
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore forwarded headers in Rewrite proxy path

Switching from Director to Rewrite changes header behavior: with Rewrite, Forwarded/X-Forwarded-* headers are stripped before your callback and are not re-added unless ProxyRequest.SetXForwarded() is called. The previous Director-based proxy automatically populated X-Forwarded-For, so this commit drops client forwarding metadata for all proxied requests. Upstreams that rely on those headers for IP-aware auth/rate-limiting/auditing will now see missing or incorrect client identity.

Useful? React with 👍 / 👎.

},
}

action := ParseAction(opts.Action)
Expand Down
Loading