Skip to content

Implement a simple 'strip prefix' feature for http locations #5276

Open
cayspekko wants to merge 2 commits intofatedier:devfrom
cayspekko:upstream/dev
Open

Implement a simple 'strip prefix' feature for http locations #5276
cayspekko wants to merge 2 commits intofatedier:devfrom
cayspekko:upstream/dev

Conversation

@cayspekko
Copy link
Copy Markdown

@cayspekko cayspekko commented Apr 3, 2026

WHY

Though frpproxy isn't meant to be a full blown L7 reverse proxy, this particular feature is useful if you use multiple dynamic paths on the server, but you don't want to hassle with url prefix logic on your http client. Especially useful for http clients that serve pure json apis. In my particular case, I cannot use domain based identifiers. Fit's naturally with the "locations" setting, and thus it only strips those particularly prefixes as they are defined.

Example:

serverAddr = "example.com"
serverPort = 7000

[[proxies]]
name = "fast"
type = "http"
localIP = "127.0.0.1"
localPort = 5000
customDomains = ["example.com"]
locations = ["/example"]
stripPrefix = true

relates to #4981

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot bot commented Apr 3, 2026

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
pkg/util/vhost/http.go 77 Prefix stripping also rewrites paths like /apiv1, so a route registered for /api can unexpectedly forward unrelated requests as /v1.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
pkg/util/vhost/router.go 113 Route matching also uses a raw HasPrefix, so /api currently matches /apiv1; the new strip behavior amplifies that existing ambiguity by rewriting the request path before forwarding.
Files Reviewed (8 files)
  • .github/workflows/build-and-push-image.yml - 0 issues
  • pkg/config/v1/proxy.go - 0 issues
  • pkg/msg/msg.go - 0 issues
  • pkg/util/vhost/http.go - 1 issue
  • pkg/util/vhost/http_test.go - 0 issues
  • pkg/util/vhost/vhost.go - 0 issues
  • server/proxy/http.go - 0 issues
  • test/e2e/v1/basic/http.go - 0 issues

Reviewed by gpt-5.4-20260305 · 291,463 tokens

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.

1 participant