Documentation
¶
Overview ¶
Package proxy abstracts Goma Gateway; TLS termination, ACME issuance and renewal are owned by Goma.
Index ¶
- Constants
- func CentralConfigKey() string
- func GomaName(workspaceID uint, name string) string
- func RenderBundle(routes []RenderedRoute, mws []RenderedMiddleware, cfgKey string) ([]byte, error)
- func RenderMiddleware(mw RenderedMiddleware) ([]byte, error)
- func RenderRoute(route RenderedRoute) ([]byte, error)
- type Backend
- type CertPair
- type Goma
- type Manager
- type MatchRule
- type Memory
- type RegistryProxy
- type RenderedMiddleware
- type RenderedRoute
- type RouteMaintenance
Constants ¶
const ConfigEncryptionKeyEnv = "GOMA_CONFIG_ENCRYPTION_KEY"
Central gateway's key only (must match its GOMA_CONFIG_ENCRYPTION_KEY); node gateways get per-node keys, see edgegateway.ConfigKey.
Variables ¶
This section is empty.
Functions ¶
func CentralConfigKey ¶ added in v1.10.6
func CentralConfigKey() string
CentralConfigKey returns the central gateway's passphrase, or "" when config encryption is off.
func RenderBundle ¶
func RenderBundle(routes []RenderedRoute, mws []RenderedMiddleware, cfgKey string) ([]byte, error)
cfgKey is that node's own key, so a bundle escaping one host is unreadable on any other; empty writes plaintext.
func RenderMiddleware ¶
func RenderMiddleware(mw RenderedMiddleware) ([]byte, error)
RenderMiddleware produces the YAML file content for a middleware, under the central gateway's key.
func RenderRoute ¶
func RenderRoute(route RenderedRoute) ([]byte, error)
Types ¶
type Backend ¶
type Backend struct {
Endpoint string // e.g. http://mb-app-1:8080
Weight int // relative weight; probability = weight / sum(weights)
Exclusive bool
Priority int
Match []MatchRule
}
A matching Exclusive backend takes all matching traffic; a non-exclusive one joins the weighted pool.
type Goma ¶
type Goma struct {
// contains filtered or unexported fields
}
Goma is driven via its file provider, which hot-reloads YAML in its watched directory.
func (*Goma) SyncRegistry ¶
func (g *Goma) SyncRegistry(_ context.Context, cfg RegistryProxy) error
Removes the file when disabled or incompletely configured; idempotent.
func (*Goma) SyncWorkspace ¶
func (g *Goma) SyncWorkspace(_ context.Context, workspaceID uint, routes []RenderedRoute, mws []RenderedMiddleware) error
Replaced atomically so Goma always reads a route together with the middlewares it references.
type Manager ¶
type Manager interface {
// Passing no routes and no middlewares removes the workspace's config entirely.
SyncWorkspace(ctx context.Context, workspaceID uint, routes []RenderedRoute, mws []RenderedMiddleware) error
SyncRegistry(ctx context.Context, cfg RegistryProxy) error
}
The workspace is the unit of sync because Goma resolves middleware references within one file.
type MatchRule ¶ added in v1.9.0
type MatchRule struct {
Source string // header | query | cookie | ip
Name string // header/query/cookie key; unused for ip
Operator string // equals | not_equals | contains | not_contains | starts_with | ends_with | regex | in
Value string // compared value; comma-separated list for `in`
}
Source, Operator and their valid values mirror the gateway's.
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) GetRoute ¶
func (m *Memory) GetRoute(id uint) (RenderedRoute, bool)
GetRoute returns the recorded route (used in tests).
func (*Memory) SyncRegistry ¶
func (m *Memory) SyncRegistry(_ context.Context, cfg RegistryProxy) error
func (*Memory) SyncWorkspace ¶
func (m *Memory) SyncWorkspace(_ context.Context, workspaceID uint, routes []RenderedRoute, mws []RenderedMiddleware) error
type RegistryProxy ¶
type RegistryProxy struct {
Enabled bool // false removes the registry config
Host string // public host, e.g. registry.<domain>
Upstream string // http://mb-registry:5000
AuthURL string // forwardAuth target, e.g. http://miabi:9000/internal/registry/auth
TLSProvider string // certManager provider ("" = gateway default)
// Replaces the tenant's header upstream, after forwardAuth has already decided; empty renders no middleware.
UpstreamAuth string
// Off behind a TLS terminator without trusted proxies, where Goma would redirect forever. See RegistryConfig.
HTTPSRedirect bool
}
type RenderedMiddleware ¶
type RenderedMiddleware struct {
ID uint
WorkspaceID uint // namespaces the Goma name (mb-ws<id>-<name>); routes reference it the same way
Name string
Type string
Paths []string
Rule map[string]interface{}
}
RenderedMiddleware is the desired Goma middleware definition.
type RenderedRoute ¶
type RenderedRoute struct {
ID uint
WorkspaceID uint // namespaces the Goma name (mb-ws<id>-<name>) to avoid cross-workspace collisions
Name string
Path string
Hosts []string
Methods []string
Rewrite string // path rewrite
Middlewares []string // referenced middleware names
Backends []Backend // one or more weighted upstreams
Certs []CertPair
// Empty means the gateway's default provider.
TLSProvider string
// Renders tls.provider "none" so the gateway never tries to obtain a cert.
TLSNone bool
// Preferred over dropping the route, which does not reliably take effect across the file and HTTP providers.
Disabled bool
// Miabi still forces name, backends and tls into it.
AdvancedYAML string
ExploitProtection bool
Maintenance *RouteMaintenance
}