ipn: add support for HTTP Redirects (#17594)
Adds a new Redirect field to HTTPHandler for serving HTTP redirects
from the Tailscale serve config. The redirect URL supports template
variables ${HOST} and ${REQUEST_URI} that are resolved per request.
By default, it redirects using HTTP Status 302 (Found). For another
redirect status, like 301 - Moved Permanently, pass the HTTP status
code followed by ':' on Redirect, like: "301:https://tailscale.com"
Updates #11252
Updates #11330
Signed-off-by: Fernando Serboncini <fserb@tailscale.com>
This commit is contained in:
committed by
GitHub
parent
05d2dcaf49
commit
d68513b0db
+10
-1
@@ -162,8 +162,17 @@ type HTTPHandler struct {
|
||||
|
||||
AcceptAppCaps []tailcfg.PeerCapability `json:",omitempty"` // peer capabilities to forward in grant header, e.g. example.com/cap/mon
|
||||
|
||||
// Redirect, if not empty, is the target URL to redirect requests to.
|
||||
// By default, we redirect with HTTP 302 (Found) status.
|
||||
// If Redirect starts with '<httpcode>:', then we use that status instead.
|
||||
//
|
||||
// The target URL supports the following expansion variables:
|
||||
// - ${HOST}: replaced with the request's Host header value
|
||||
// - ${REQUEST_URI}: replaced with the request's full URI (path and query string)
|
||||
Redirect string `json:",omitempty"`
|
||||
|
||||
// TODO(bradfitz): bool to not enumerate directories? TTL on mapping for
|
||||
// temporary ones? Error codes? Redirects?
|
||||
// temporary ones? Error codes?
|
||||
}
|
||||
|
||||
// WebHandlerExists reports whether if the ServeConfig Web handler exists for
|
||||
|
||||
Reference in New Issue
Block a user