Repository navigation
feat(vhost): support custom error pages via server config - #5610
Tommickey2020gmail wants to merge 1 commit into
Conversation
Add customErrorPages to the frps config so users can customize error responses generated by frps itself (404 no route, 504 proxy timeout, 401/407 auth failed) with inline body content, without mounting files into the container. For status code 404, the existing custom404Page file takes precedence over a customErrorPages entry.
| # statusCode = 504 | ||
| # contentType = "text/html" | ||
| # body = "Service temporarily unavailable, please try again later." | ||
| # [customErrorPages.headers] |
There was a problem hiding this comment.
WARNING: Move the error-page examples below the remaining root settings
Uncommenting these examples in their current location leaves TOML inside [customErrorPages.headers], so the following udpPacketSize = 1500 and natholeAnalysisDataReserveHours = 168 become response-header entries instead of server settings. Configuration loading then fails because CustomErrorPage.Headers is a map[string]string but those values are numbers, even with strict parsing disabled. Enabling only the 404 example also captures those settings inside its array element and fails default strict parsing. Move the entire example block after the remaining root/dotted settings, immediately before [[httpPlugins]], so enabling this documented option does not prevent frps from starting.
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (7 files)
Static review of all changed files at Fix these issues in Kilo Cloud Reviewed by gpt-6.1-sol · Input: 45 · Output: 6.1K · Cached: 694.6K |
Summary
Adds a new
customErrorPagesoption to the frps config that lets users customize the error responses frps generates itself, using inline content in the config file — no HTML files need to be mounted into the frps container/image.This complements the existing
custom404Page(file path) option:custom404Pagestill works and takes precedence for 404 responses.customErrorPagescovers any 4xx/5xx status code frps can emit on the vhost ports: 404 (no route found), 504 (proxy timeout — previously an empty body), 401 (vhost basic auth), 407 (proxy auth).statusCode,contentType(defaulttext/html), inlinebody, and extraheaders(e.g.Retry-After).Example (
frps.toml):Use case: operators who expose frps vhost ports directly (e.g. in Docker) can brand the error page to match their own system and show support contact info, without building custom images or running a reverse proxy in front.
Test plan
go test ./pkg/util/vhost ./pkg/config/...— new unit tests inpkg/util/vhost/resource_test.gocover precedence (file > inline > default), custom headers/content type, andNotFoundResponsego vetcleanconfig.LoadServerConfig(strict mode), including multi-linebodyand[customErrorPages.headers]