Skip to content

[Feature Request] Custom response for unregistered HTTP vhost (rules, wildcard, headers) #4972

@mnasruul

Description

@mnasruul

Describe the feature request

Summary

Add support for configurable customResponse in FRPS HTTP vhost, so requests with unknown/unregistered Host header return a user-defined response (status, content-type, body, headers).

Why

Currently, FRPS always returns default 404 for unregistered hostnames. This is not customizable. Custom responses improve UX and debugging, especially in multi-tenant setups.

## Proposed config (TOML)
[customResponse]
enable = false

[[customResponse.rules]]
hostname    = ["*.example.com", "example.com"]
statusCode  = 503
contentType = "text/html"
body = """
<!doctype html><html><body>
<h1>Service Unavailable</h1>
<p>The server is currently unavailable.<br/>Please try again later.</p>
</body></html>
"""
[customResponse.rules.headers]
Cache-Control = "no-store"
X-Error-Code  = "UNREGISTERED_HOST"

[[customResponse.rules]]
hostname    = ["spesific.example2.com"]
statusCode  = 404
contentType = "application/json"
body        = "{\"error\":\"unregistered_host\",\"hint\":\"register frpc for this hostname\"}"
[customResponse.rules.headers]
Cache-Control = "no-store"

Behavior

  • If feature disabled, behavior unchanged (default 404).
  • Rules support exact, wildcard (*.example.com), and "*" catch-all.
  • First match wins.

Next step

I can prepare a PR with implementation + unit tests if this direction is acceptable.

Describe alternatives you've considered

No response

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions