[management,proxy] Add per-target options to reverse proxy (#5501)

This commit is contained in:
Viktor Liu
2026-03-05 17:03:26 +08:00
committed by GitHub
parent 8e7b016be2
commit e601278117
16 changed files with 1599 additions and 445 deletions

View File

@@ -3027,6 +3027,28 @@ components:
- targets
- auth
- enabled
ServiceTargetOptions:
type: object
properties:
skip_tls_verify:
type: boolean
description: Skip TLS certificate verification for this backend
request_timeout:
type: string
description: Per-target response timeout as a Go duration string (e.g. "30s", "2m")
path_rewrite:
type: string
description: Controls how the request path is rewritten before forwarding to the backend. Default strips the matched prefix. "preserve" keeps the full original request path.
enum: [preserve]
custom_headers:
type: object
description: Extra headers sent to the backend. Hop-by-hop and proxy-managed headers (Host, Connection, Transfer-Encoding, etc.) are rejected.
propertyNames:
type: string
pattern: '^[!#$%&''*+.^_`|~0-9A-Za-z-]+$'
additionalProperties:
type: string
pattern: '^[^\r\n]*$'
ServiceTarget:
type: object
properties:
@@ -3053,6 +3075,8 @@ components:
enabled:
type: boolean
description: Whether this target is enabled
options:
$ref: '#/components/schemas/ServiceTargetOptions'
required:
- target_id
- target_type

View File

@@ -326,6 +326,11 @@ const (
ServiceTargetTargetTypeResource ServiceTargetTargetType = "resource"
)
// Defines values for ServiceTargetOptionsPathRewrite.
const (
ServiceTargetOptionsPathRewritePreserve ServiceTargetOptionsPathRewrite = "preserve"
)
// Defines values for TenantResponseStatus.
const (
TenantResponseStatusActive TenantResponseStatus = "active"
@@ -367,6 +372,27 @@ const (
GetApiEventsNetworkTrafficParamsDirectionINGRESS GetApiEventsNetworkTrafficParamsDirection = "INGRESS"
)
// Defines values for GetApiEventsProxyParamsSortBy.
const (
GetApiEventsProxyParamsSortByAuthMethod GetApiEventsProxyParamsSortBy = "auth_method"
GetApiEventsProxyParamsSortByDuration GetApiEventsProxyParamsSortBy = "duration"
GetApiEventsProxyParamsSortByHost GetApiEventsProxyParamsSortBy = "host"
GetApiEventsProxyParamsSortByMethod GetApiEventsProxyParamsSortBy = "method"
GetApiEventsProxyParamsSortByPath GetApiEventsProxyParamsSortBy = "path"
GetApiEventsProxyParamsSortByReason GetApiEventsProxyParamsSortBy = "reason"
GetApiEventsProxyParamsSortBySourceIp GetApiEventsProxyParamsSortBy = "source_ip"
GetApiEventsProxyParamsSortByStatusCode GetApiEventsProxyParamsSortBy = "status_code"
GetApiEventsProxyParamsSortByTimestamp GetApiEventsProxyParamsSortBy = "timestamp"
GetApiEventsProxyParamsSortByUrl GetApiEventsProxyParamsSortBy = "url"
GetApiEventsProxyParamsSortByUserId GetApiEventsProxyParamsSortBy = "user_id"
)
// Defines values for GetApiEventsProxyParamsSortOrder.
const (
GetApiEventsProxyParamsSortOrderAsc GetApiEventsProxyParamsSortOrder = "asc"
GetApiEventsProxyParamsSortOrderDesc GetApiEventsProxyParamsSortOrder = "desc"
)
// Defines values for GetApiEventsProxyParamsMethod.
const (
GetApiEventsProxyParamsMethodDELETE GetApiEventsProxyParamsMethod = "DELETE"
@@ -2741,7 +2767,8 @@ type ServiceTarget struct {
Enabled bool `json:"enabled"`
// Host Backend ip or domain for this target
Host *string `json:"host,omitempty"`
Host *string `json:"host,omitempty"`
Options *ServiceTargetOptions `json:"options,omitempty"`
// Path URL path prefix for this target
Path *string `json:"path,omitempty"`
@@ -2765,6 +2792,24 @@ type ServiceTargetProtocol string
// ServiceTargetTargetType Target type (e.g., "peer", "resource")
type ServiceTargetTargetType string
// ServiceTargetOptions defines model for ServiceTargetOptions.
type ServiceTargetOptions struct {
// CustomHeaders Extra headers sent to the backend. Hop-by-hop and proxy-managed headers (Host, Connection, Transfer-Encoding, etc.) are rejected.
CustomHeaders *map[string]string `json:"custom_headers,omitempty"`
// PathRewrite Controls how the request path is rewritten before forwarding to the backend. Default strips the matched prefix. "preserve" keeps the full original request path.
PathRewrite *ServiceTargetOptionsPathRewrite `json:"path_rewrite,omitempty"`
// RequestTimeout Per-target response timeout as a Go duration string (e.g. "30s", "2m")
RequestTimeout *string `json:"request_timeout,omitempty"`
// SkipTlsVerify Skip TLS certificate verification for this backend
SkipTlsVerify *bool `json:"skip_tls_verify,omitempty"`
}
// ServiceTargetOptionsPathRewrite Controls how the request path is rewritten before forwarding to the backend. Default strips the matched prefix. "preserve" keeps the full original request path.
type ServiceTargetOptionsPathRewrite string
// SetupKey defines model for SetupKey.
type SetupKey struct {
// AllowExtraDnsLabels Allow extra DNS labels to be added to the peer
@@ -3335,6 +3380,12 @@ type GetApiEventsProxyParams struct {
// PageSize Number of items per page (max 100)
PageSize *int `form:"page_size,omitempty" json:"page_size,omitempty"`
// SortBy Field to sort by (url sorts by host then path)
SortBy *GetApiEventsProxyParamsSortBy `form:"sort_by,omitempty" json:"sort_by,omitempty"`
// SortOrder Sort order (ascending or descending)
SortOrder *GetApiEventsProxyParamsSortOrder `form:"sort_order,omitempty" json:"sort_order,omitempty"`
// Search General search across request ID, host, path, source IP, user email, and user name
Search *string `form:"search,omitempty" json:"search,omitempty"`
@@ -3372,6 +3423,12 @@ type GetApiEventsProxyParams struct {
EndDate *time.Time `form:"end_date,omitempty" json:"end_date,omitempty"`
}
// GetApiEventsProxyParamsSortBy defines parameters for GetApiEventsProxy.
type GetApiEventsProxyParamsSortBy string
// GetApiEventsProxyParamsSortOrder defines parameters for GetApiEventsProxy.
type GetApiEventsProxyParamsSortOrder string
// GetApiEventsProxyParamsMethod defines parameters for GetApiEventsProxy.
type GetApiEventsProxyParamsMethod string