nginx

package
v3.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ReloadForEndpointsUpdate means that is caused by an endpoints update.
	ReloadForEndpointsUpdate = true
	// ReloadForOtherUpdate means that a reload is caused by an update for a resource(s) other than endpoints.
	ReloadForOtherUpdate = false
	// TLSSecretFileMode defines the default filemode for files with TLS Secrets.
	TLSSecretFileMode = 0o600
	// JWKSecretFileMode defines the default filemode for files with JWK Secrets.
	JWKSecretFileMode = 0o644
	// HtpasswdSecretFileMode defines the default filemode for HTTP basic auth user files.
	HtpasswdSecretFileMode = 0o644
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeManager

type FakeManager struct {
	// contains filtered or unexported fields
}

FakeManager provides a fake implementation of the Manager interface.

func NewFakeManager

func NewFakeManager(confPath string) *FakeManager

NewFakeManager creates a FakeManager.

func (*FakeManager) AppProtectDosAgentQuit

func (*FakeManager) AppProtectDosAgentQuit()

AppProtectDosAgentQuit is a fake implementation AppProtectAgentQuit

func (*FakeManager) AppProtectDosAgentStart

func (*FakeManager) AppProtectDosAgentStart(_ chan error, _ bool, _ int, _ int, _ int)

AppProtectDosAgentStart is a fake implementation of AppProtectAgentStart

func (*FakeManager) AppProtectPluginQuit

func (*FakeManager) AppProtectPluginQuit()

AppProtectPluginQuit is a fake implementation AppProtectPluginQuit

func (*FakeManager) AppProtectPluginStart

func (*FakeManager) AppProtectPluginStart(_ chan error, _ string)

AppProtectPluginStart is a fake implementation AppProtectPluginStart

func (*FakeManager) ClearAppProtectFolder

func (*FakeManager) ClearAppProtectFolder(name string)

ClearAppProtectFolder provides a fake implementation of ClearAppProtectFolder

func (*FakeManager) CreateAppProtectResourceFile

func (*FakeManager) CreateAppProtectResourceFile(name string, content []byte)

CreateAppProtectResourceFile provides a fake implementation of CreateAppProtectResourceFile

func (*FakeManager) CreateConfig

func (*FakeManager) CreateConfig(name string, content []byte) bool

CreateConfig provides a fake implementation of CreateConfig.

func (*FakeManager) CreateDHParam

func (fm *FakeManager) CreateDHParam(_ string) (string, error)

CreateDHParam provides a fake implementation of CreateDHParam.

func (*FakeManager) CreateMainConfig

func (*FakeManager) CreateMainConfig(content []byte) bool

CreateMainConfig provides a fake implementation of CreateMainConfig.

func (*FakeManager) CreateOpenTracingTracerConfig

func (*FakeManager) CreateOpenTracingTracerConfig(_ string) error

CreateOpenTracingTracerConfig creates a fake implementation of CreateOpenTracingTracerConfig.

func (*FakeManager) CreateSecret

func (fm *FakeManager) CreateSecret(name string, _ []byte, _ os.FileMode) string

CreateSecret provides a fake implementation of CreateSecret.

func (*FakeManager) CreateStreamConfig

func (*FakeManager) CreateStreamConfig(name string, content []byte) bool

CreateStreamConfig provides a fake implementation of CreateStreamConfig.

func (*FakeManager) CreateTLSPassthroughHostsConfig

func (*FakeManager) CreateTLSPassthroughHostsConfig(_ []byte) bool

CreateTLSPassthroughHostsConfig provides a fake implementation of CreateTLSPassthroughHostsConfig.

func (*FakeManager) DeleteAppProtectResourceFile

func (*FakeManager) DeleteAppProtectResourceFile(name string)

DeleteAppProtectResourceFile provides a fake implementation of DeleteAppProtectResourceFile

func (*FakeManager) DeleteConfig

func (*FakeManager) DeleteConfig(name string)

DeleteConfig provides a fake implementation of DeleteConfig.

func (*FakeManager) DeleteSecret

func (*FakeManager) DeleteSecret(name string)

DeleteSecret provides a fake implementation of DeleteSecret.

func (*FakeManager) DeleteStreamConfig

func (*FakeManager) DeleteStreamConfig(name string)

DeleteStreamConfig provides a fake implementation of DeleteStreamConfig.

func (*FakeManager) GetFilenameForSecret

func (fm *FakeManager) GetFilenameForSecret(name string) string

GetFilenameForSecret provides a fake implementation of GetFilenameForSecret.

func (*FakeManager) GetSecretsDir

func (fm *FakeManager) GetSecretsDir() string

GetSecretsDir is a fake implementation

func (*FakeManager) Quit

func (*FakeManager) Quit()

Quit provides a fake implementation of Quit.

func (*FakeManager) Reload

func (*FakeManager) Reload(_ bool) error

Reload provides a fake implementation of Reload.

func (*FakeManager) SetOpenTracing

func (*FakeManager) SetOpenTracing(_ bool)

SetOpenTracing creates a fake implementation of SetOpenTracing.

func (*FakeManager) SetPlusClients

func (*FakeManager) SetPlusClients(_ *client.NginxClient, _ *http.Client)

SetPlusClients provides a fake implementation of SetPlusClients.

func (*FakeManager) Start

func (*FakeManager) Start(_ chan error)

Start provides a fake implementation of Start.

func (*FakeManager) UpdateConfigVersionFile

func (*FakeManager) UpdateConfigVersionFile(_ bool)

UpdateConfigVersionFile provides a fake implementation of UpdateConfigVersionFile.

func (*FakeManager) UpdateServersInPlus

func (*FakeManager) UpdateServersInPlus(upstream string, servers []string, _ ServerConfig) error

UpdateServersInPlus provides a fake implementation of UpdateServersInPlus.

func (*FakeManager) UpdateStreamServersInPlus

func (*FakeManager) UpdateStreamServersInPlus(upstream string, servers []string) error

UpdateStreamServersInPlus provides a fake implementation of UpdateStreamServersInPlus.

func (*FakeManager) Version

func (*FakeManager) Version() Version

Version provides a fake implementation of Version.

type LocalManager

type LocalManager struct {
	OpenTracing bool
	// contains filtered or unexported fields
}

LocalManager updates NGINX configuration, starts, reloads and quits NGINX, updates NGINX Plus upstream servers. It assumes that NGINX is running in the same container.

func NewLocalManager

func NewLocalManager(confPath string, debug bool, mc collectors.ManagerCollector, timeout time.Duration) *LocalManager

NewLocalManager creates a LocalManager.

func (*LocalManager) AppProtectDosAgentQuit

func (lm *LocalManager) AppProtectDosAgentQuit()

AppProtectDosAgentQuit gracefully ends AppProtect Agent.

func (*LocalManager) AppProtectDosAgentStart

func (lm *LocalManager) AppProtectDosAgentStart(apdaDone chan error, debug bool, maxDaemon int, maxWorkers int, memory int)

AppProtectDosAgentStart starts the AppProtectDos agent

func (*LocalManager) AppProtectPluginQuit

func (lm *LocalManager) AppProtectPluginQuit()

AppProtectPluginQuit gracefully ends AppProtect Agent.

func (*LocalManager) AppProtectPluginStart

func (lm *LocalManager) AppProtectPluginStart(appDone chan error, logLevel string)

AppProtectPluginStart starts the AppProtect plugin and sets AppProtect log level.

func (*LocalManager) ClearAppProtectFolder

func (lm *LocalManager) ClearAppProtectFolder(name string)

ClearAppProtectFolder clears contents of a config folder

func (*LocalManager) CreateAppProtectResourceFile

func (lm *LocalManager) CreateAppProtectResourceFile(name string, content []byte)

CreateAppProtectResourceFile writes contents of An App Protect resource to a file

func (*LocalManager) CreateConfig

func (lm *LocalManager) CreateConfig(name string, content []byte) bool

CreateConfig creates a configuration file. If the file already exists, it will be overridden.

func (*LocalManager) CreateDHParam

func (lm *LocalManager) CreateDHParam(content string) (string, error)

CreateDHParam creates the servers dhparam.pem file. If the file already exists, it will be overridden.

func (*LocalManager) CreateMainConfig

func (lm *LocalManager) CreateMainConfig(content []byte) bool

CreateMainConfig creates the main NGINX configuration file. If the file already exists, it will be overridden.

func (*LocalManager) CreateOpenTracingTracerConfig

func (lm *LocalManager) CreateOpenTracingTracerConfig(content string) error

CreateOpenTracingTracerConfig creates a json configuration file for the OpenTracing tracer with the content of the string.

func (*LocalManager) CreateSecret

func (lm *LocalManager) CreateSecret(name string, content []byte, mode os.FileMode) string

CreateSecret creates a secret file with the specified name, content and mode. If the file already exists, it will be overridden.

func (*LocalManager) CreateStreamConfig

func (lm *LocalManager) CreateStreamConfig(name string, content []byte) bool

CreateStreamConfig creates a configuration file for stream module. If the file already exists, it will be overridden.

func (*LocalManager) CreateTLSPassthroughHostsConfig

func (lm *LocalManager) CreateTLSPassthroughHostsConfig(content []byte) bool

CreateTLSPassthroughHostsConfig creates a configuration file with mapping between TLS Passthrough hosts and the corresponding unix sockets. If the file already exists, it will be overridden.

func (*LocalManager) DeleteAppProtectResourceFile

func (lm *LocalManager) DeleteAppProtectResourceFile(name string)

DeleteAppProtectResourceFile removes an App Protect resource file from storage

func (*LocalManager) DeleteConfig

func (lm *LocalManager) DeleteConfig(name string)

DeleteConfig deletes the configuration file from the conf.d folder.

func (*LocalManager) DeleteSecret

func (lm *LocalManager) DeleteSecret(name string)

DeleteSecret the file with the secret.

func (*LocalManager) DeleteStreamConfig

func (lm *LocalManager) DeleteStreamConfig(name string)

DeleteStreamConfig deletes the configuration file from the stream-conf.d folder.

func (*LocalManager) GetFilenameForSecret

func (lm *LocalManager) GetFilenameForSecret(name string) string

GetFilenameForSecret constructs the filename for the secret

func (*LocalManager) GetSecretsDir

func (lm *LocalManager) GetSecretsDir() string

GetSecretsDir allows the static config params to reference the secrets directory

func (*LocalManager) Quit

func (lm *LocalManager) Quit()

Quit shutdowns NGINX gracefully.

func (*LocalManager) Reload

func (lm *LocalManager) Reload(isEndpointsUpdate bool) error

Reload reloads NGINX.

func (*LocalManager) SetOpenTracing

func (lm *LocalManager) SetOpenTracing(openTracing bool)

SetOpenTracing sets the value of OpenTracing for the Manager

func (*LocalManager) SetPlusClients

func (lm *LocalManager) SetPlusClients(plusClient *client.NginxClient, plusConfigVersionCheckClient *http.Client)

SetPlusClients sets the necessary clients to work with NGINX Plus API. If not set, invoking the UpdateServersInPlus will fail.

func (*LocalManager) Start

func (lm *LocalManager) Start(done chan error)

Start starts NGINX.

func (*LocalManager) UpdateConfigVersionFile

func (lm *LocalManager) UpdateConfigVersionFile(openTracing bool)

UpdateConfigVersionFile writes the config version file.

func (*LocalManager) UpdateServersInPlus

func (lm *LocalManager) UpdateServersInPlus(upstream string, servers []string, config ServerConfig) error

UpdateServersInPlus updates NGINX Plus servers of the given upstream.

func (*LocalManager) UpdateStreamServersInPlus

func (lm *LocalManager) UpdateStreamServersInPlus(upstream string, servers []string) error

UpdateStreamServersInPlus updates NGINX Plus stream servers of the given upstream.

func (*LocalManager) Version

func (lm *LocalManager) Version() Version

Version returns NGINX version

type Manager

type Manager interface {
	CreateMainConfig(content []byte) bool
	CreateConfig(name string, content []byte) bool
	DeleteConfig(name string)
	CreateStreamConfig(name string, content []byte) bool
	DeleteStreamConfig(name string)
	CreateTLSPassthroughHostsConfig(content []byte) bool
	CreateSecret(name string, content []byte, mode os.FileMode) string
	DeleteSecret(name string)
	CreateAppProtectResourceFile(name string, content []byte)
	DeleteAppProtectResourceFile(name string)
	ClearAppProtectFolder(name string)
	GetFilenameForSecret(name string) string
	CreateDHParam(content string) (string, error)
	CreateOpenTracingTracerConfig(content string) error
	Start(done chan error)
	Version() Version
	Reload(isEndpointsUpdate bool) error
	Quit()
	UpdateConfigVersionFile(openTracing bool)
	SetPlusClients(plusClient *client.NginxClient, plusConfigVersionCheckClient *http.Client)
	UpdateServersInPlus(upstream string, servers []string, config ServerConfig) error
	UpdateStreamServersInPlus(upstream string, servers []string) error
	SetOpenTracing(openTracing bool)
	AppProtectPluginStart(appDone chan error, logLevel string)
	AppProtectPluginQuit()
	AppProtectDosAgentStart(apdaDone chan error, debug bool, maxDaemon int, maxWorkers int, memory int)
	AppProtectDosAgentQuit()
	GetSecretsDir() string
}

The Manager interface updates NGINX configuration, starts, reloads and quits NGINX, updates NGINX Plus upstream servers.

type ServerConfig

type ServerConfig struct {
	MaxFails    int
	MaxConns    int
	FailTimeout string
	SlowStart   string
}

ServerConfig holds the config data for an upstream server in NGINX Plus.

type Version

type Version struct {
	OSS    string
	IsPlus bool
	Plus   string
	// contains filtered or unexported fields
}

Version holds the parsed output from `nginx -v`

func NewVersion

func NewVersion(line string) Version

NewVersion will take the output from `nginx -v` and explodes it into the `nginx.Version` struct

func (Version) PlusGreaterThanOrEqualTo

func (v Version) PlusGreaterThanOrEqualTo(target string) (bool, error)

PlusGreaterThanOrEqualTo compares the supplied nginx-plus version string with the Version{} struct

func (*Version) String

func (v *Version) String() string

Return the raw Nginx version string from `nginx -v`

Jump to

Keyboard shortcuts

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