Documentation
¶
Index ¶
- Constants
- Variables
- func BuildRestoreConfig(backupPath, currentPath string, preserveProtected bool) ([]byte, []string, error)
- func Init(confPath string)
- func ReloadCluster() (err error)
- func Save() (err error)
- func Update(fn func()) (err error)
- type Auth
- type Backup
- type Casdoor
- type Cert
- type Cluster
- type Crypto
- type Database
- type HTTP
- type Logrotate
- type Nginx
- type NginxLog
- type Node
- type OIDC
- type OpenAI
- type SiteCheck
- type Terminal
- type UpstreamCheck
- type WebAuthn
Constants ¶
const ( OpenAIProviderOpenAI = "openai" OpenAIProviderAtlasCloud = "atlas_cloud" OpenAIProviderMiniMax = "minimax" OpenAIProviderCustom = "custom" AtlasCloudBaseURL = "https://api.atlascloud.ai/v1" MiniMaxGlobalOpenAIURL = "https://api.minimax.io/v1" MiniMaxCNOpenAIURL = "https://api.minimaxi.com/v1" )
const InvalidLogrotateIntervalMessage = "logrotate interval must be greater than 0"
const RedactedSensitiveValue = "__NGINX_UI_REDACTED__"
RedactedSensitiveValue is the sentinel string returned in place of sensitive setting values (secrets, tokens, IP allow-list entries) by the settings API. Payloads that echo it back are treated as "keep the current value" rather than an actual user-supplied override.
Variables ¶
var ( LastModified string EnvPrefix = "NGINX_UI_" )
var AuthSettings = &Auth{
BanThresholdMinutes: 10,
MaxAttempts: 10,
}
var BackupSettings = &Backup{ GrantedAccessPath: []string{}, }
BackupSettings is the global configuration instance for backup operations. This variable holds the current backup security settings and access permissions.
Default configuration:
- GrantedAccessPath: Empty list (no paths allowed by default for security)
To enable backup functionality, administrators must explicitly configure allowed paths through the settings interface or configuration file.
var CasdoorSettings = &Casdoor{}
var CertSettings = &Cert{ Email: "", CADir: "", RenewalInterval: 30, RecursiveNameservers: []string{}, HTTPChallengePort: "9180", }
var ClusterSettings = &Cluster{ Node: []string{}, }
var CryptoSettings = &Crypto{}
var DatabaseSettings = &Database{
Name: "database",
}
var HTTPSettings = &HTTP{ WebSocketTrustedOrigins: []string{}, }
var LogrotateSettings = &Logrotate{ Enabled: false, CMD: "logrotate /etc/logrotate.d/nginx", Interval: defaultLogrotateIntervalMinutes, }
var NginxLogSettings = &NginxLog{}
var NginxSettings = &Nginx{}
var NodeSettings = &Node{}
var OIDCSettings = &OIDC{}
var OpenAISettings = &OpenAI{ Provider: OpenAIProviderOpenAI, APIType: string(openai.APITypeOpenAI), }
var SiteCheckSettings = &SiteCheck{ Enabled: true, Concurrency: defaultSiteCheckConcurrency, IntervalSeconds: defaultSiteCheckIntervalSeconds, }
var TerminalSettings = &Terminal{
StartCmd: "login",
}
var UpstreamCheckSettings = &UpstreamCheck{ Enabled: true, IntervalSeconds: defaultUpstreamCheckIntervalSeconds, }
var WebAuthnSettings = &WebAuthn{}
Functions ¶
func BuildRestoreConfig ¶
func BuildRestoreConfig(backupPath, currentPath string, preserveProtected bool) ([]byte, []string, error)
BuildRestoreConfig parses and validates a backup configuration. Portable restores copy every field except destination-owned protected settings.
func ReloadCluster ¶
func ReloadCluster() (err error)
Types ¶
type Backup ¶
type Backup struct {
// GrantedAccessPath defines the list of directory paths that are allowed for backup operations.
// All backup source paths and storage destination paths must be within one of these directories.
// This security measure prevents unauthorized access to sensitive system directories.
//
// Examples:
// - "/tmp" - Allow backups in temporary directory
// - "/var/backups" - Allow backups in system backup directory
// - "/home/user/backups" - Allow backups in user's backup directory
//
// Note: Paths are checked using prefix matching, so "/tmp" allows "/tmp/backup" but not "/tmpfoo"
GrantedAccessPath []string `json:"granted_access_path" ini:",,allowshadow"`
}
Backup contains configuration settings for backup operations. This structure defines security constraints and access permissions for backup functionality.
type Casdoor ¶
type Casdoor struct {
Endpoint string `json:"endpoint" protected:"true"`
ExternalUrl string `json:"external_url" protected:"true"`
ClientId string `json:"client_id" protected:"true"`
ClientSecret string `json:"client_secret" protected:"true" sensitive:"true"`
CertificatePath string `json:"certificate_path" protected:"true"`
Organization string `json:"organization" protected:"true"`
Application string `json:"application" protected:"true"`
RedirectUri string `json:"redirect_uri" protected:"true"`
}
type Cert ¶
type Cert struct {
Email string `json:"email" protected:"true"`
CADir string `json:"ca_dir" binding:"omitempty,url"`
RenewalInterval int `json:"renewal_interval" binding:"min=1,max=90"`
RecursiveNameservers []string `json:"recursive_nameservers" binding:"omitempty,dive,hostname_port"`
HTTPChallengePort string `json:"http_challenge_port"`
}
func (*Cert) GetCertRenewalInterval ¶
GetCertRenewalInterval returns the configured remaining-validity threshold in days.
type Cluster ¶
type Cluster struct {
Node []string `json:"node" ini:",,allowshadow" protected:"true" sensitive:"true"`
}
type Crypto ¶
type Crypto struct {
Secret string `json:"secret" protected:"true" sensitive:"true"`
}
func (*Crypto) GetSecretMd5 ¶
type Logrotate ¶
type Logrotate struct {
Enabled bool `json:"enabled"`
CMD string `json:"cmd" protected:"true"`
Interval int `json:"interval" binding:"omitempty,min=1"`
}
func (*Logrotate) GetInterval ¶
Pointer receiver so the call reads only Interval rather than copying the whole struct, which would make it race with any concurrent settings write.
func (Logrotate) HasValidInterval ¶
type Nginx ¶
type Nginx struct {
AccessLogPath string `json:"access_log_path" protected:"true"`
ErrorLogPath string `json:"error_log_path" protected:"true"`
LogDirWhiteList []string `json:"log_dir_white_list" protected:"true"`
ConfigDir string `json:"config_dir" protected:"true"`
ConfigPath string `json:"config_path" protected:"true"`
PIDPath string `json:"pid_path" protected:"true"`
SbinPath string `json:"sbin_path" protected:"true"`
TestConfigCmd string `json:"test_config_cmd" protected:"true"`
ReloadCmd string `json:"reload_cmd" protected:"true"`
RestartCmd string `json:"restart_cmd" protected:"true"`
StubStatusPort uint `json:"stub_status_port" binding:"omitempty,min=1,max=65535"`
ContainerName string `json:"container_name" protected:"true"`
MaintenanceTemplate string `json:"maintenance_template"`
}
func (*Nginx) GetStubStatusPort ¶
func (*Nginx) RunningInAnotherContainer ¶
type NginxLog ¶
type NginxLog struct {
IndexingEnabled bool `json:"indexing_enabled"`
IndexPath string `json:"index_path"`
// IncrementalIndexInterval controls how often the incremental indexing job runs, in minutes.
// When set to 0 or a negative value, a conservative default will be used.
IncrementalIndexInterval int `json:"incremental_index_interval"`
// MaxConcurrentIndexTasks caps how many log groups are indexed at the same
// time. Each concurrent group buffers a parse batch and an index batch per
// rotated file, so this is the main lever on peak indexing memory.
// When set to 0 or a negative value, the value is derived from the CPU
// budget the process is allowed to use.
MaxConcurrentIndexTasks int `json:"max_concurrent_index_tasks"`
}
func (*NginxLog) GetIncrementalIndexInterval ¶
GetIncrementalIndexInterval returns the effective incremental indexing interval. Defaults to 15 minutes when not configured or configured with an invalid value.
type Node ¶
type Node struct {
Name string `json:"name" binding:"omitempty,safety_text"`
Secret string `json:"secret" protected:"true" sensitive:"true"`
InstanceID string `json:"instance_id" protected:"true"`
SkipInstallation bool `json:"skip_installation" protected:"true"`
Demo bool `json:"demo" protected:"true"`
ICPNumber string `json:"icp_number" binding:"omitempty,safety_text"`
PublicSecurityNumber string `json:"public_security_number" binding:"omitempty,safety_text"`
}
type OIDC ¶
type OIDC struct {
ClientId string `json:"client_id" protected:"true"`
ClientSecret string `json:"client_secret" protected:"true" sensitive:"true"`
Endpoint string `json:"endpoint" protected:"true"`
RedirectUri string `json:"redirect_uri" protected:"true"`
Scopes string `json:"scopes" protected:"true"`
Identifier string `json:"identifier" protected:"true"`
}
type OpenAI ¶
type OpenAI struct {
Provider string `json:"provider" binding:"omitempty,oneof=openai atlas_cloud minimax custom"`
BaseUrl string `json:"base_url" binding:"omitempty,url"`
Token string `json:"token" binding:"omitempty,safety_text" sensitive:"true"`
Proxy string `json:"proxy" binding:"omitempty,url"`
Model string `json:"model" binding:"omitempty,safety_text"`
APIType string `json:"api_type" binding:"omitempty,oneof=OPEN_AI AZURE"`
EnableCodeCompletion bool `json:"enable_code_completion" binding:"omitempty"`
CodeCompletionModel string `json:"code_completion_model" binding:"omitempty,safety_text"`
}
func (*OpenAI) GetBaseURL ¶
func (*OpenAI) GetCodeCompletionModel ¶
func (*OpenAI) GetProvider ¶
type SiteCheck ¶
type SiteCheck struct {
Enabled bool `json:"enabled"`
Concurrency int `json:"concurrency" binding:"omitempty,min=1,max=20"`
IntervalSeconds int `json:"interval_seconds" binding:"omitempty,min=30"`
}
func (*SiteCheck) GetConcurrency ¶
GetConcurrency returns the configured concurrency, clamped to a safe range.
Pointer receiver on purpose. A value receiver copies the whole struct on every call, so the periodic check loop was reading Enabled once a tick even though it only wants Concurrency — enough for the race detector to flag it against any test that toggles Enabled. Reading just the field also avoids a struct copy in a hot loop.
func (*SiteCheck) GetInterval ¶
GetInterval returns the periodic sweep interval, clamped to a safe minimum. Pointer receiver for the same reason as GetConcurrency.
type UpstreamCheck ¶
type UpstreamCheck struct {
Enabled bool `json:"enabled"`
IntervalSeconds int `json:"interval_seconds" binding:"omitempty,min=5"`
}
func (*UpstreamCheck) GetInterval ¶
func (s *UpstreamCheck) GetInterval() time.Duration
Pointer receiver so the call reads only the interval field rather than copying the whole struct, which would make it race with concurrent writes.