proxy

package
v1.10.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package proxy abstracts Goma Gateway; TLS termination, ACME issuance and renewal are owned by Goma.

Index

Constants

View Source
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 GomaName added in v1.6.0

func GomaName(workspaceID uint, name string) string

Lets analytics consumers map a gateway event back to its route.

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 CertPair

type CertPair struct {
	CertPEM string
	KeyPEM  string
}

CertPair is a user-supplied (custom) certificate, inlined as PEM.

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 NewGoma

func NewGoma(dir string) *Goma

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 NewMemory

func NewMemory() *Memory

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
}

type RouteMaintenance added in v1.8.3

type RouteMaintenance struct {
	Enabled    bool
	StatusCode int
	Message    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL