feat(proxy): Support independent configuration for service domain and tunnel domain

- Add serverDomain and tunnelDomain fields to the Handler struct to distinguish between service domain and tunnel domain
- Modify the NewHandler function signature to support passing two separate domain parameters
- Update the extractSubdomain method to return a subdomain result type with three states: home, found, notFound
- Add serveTunnelNotFound method to handle tunnel not found cases, returning a 404 page
- Add favicon support to display an icon on the page
- Adjust routing logic to display a dedicated 404 page when accessing a tunnel domain but the corresponding tunnel is not found
This commit is contained in:
Gouryella
2026-01-16 17:18:43 +08:00
parent 73fa51480d
commit 10aa65065a
3 changed files with 109 additions and 13 deletions

View File

@@ -285,7 +285,7 @@ func runServer(cmd *cobra.Command, _ []string) error {
listenAddr := fmt.Sprintf("0.0.0.0:%d", cfg.Port)
httpHandler := proxy.NewHandler(tunnelManager, logger, cfg.TunnelDomain, cfg.AuthToken, cfg.MetricsToken)
httpHandler := proxy.NewHandler(tunnelManager, logger, cfg.Domain, cfg.TunnelDomain, cfg.AuthToken, cfg.MetricsToken)
httpHandler.SetAllowedTransports(cfg.AllowedTransports)
httpHandler.SetAllowedTunnelTypes(cfg.AllowedTunnelTypes)