Documentation ¶
Index ¶
- Constants
- Variables
- func AllLocationPatternTypes() []maps.Map
- func AllNodeRoles() []string
- func AllRequestOperators() []maps.Map
- func AllWebsocketForwardModes() []maps.Map
- func ExistNodeRole(role NodeRole) bool
- func FindLocationPatternType(patternType int) maps.Map
- func FindLocationPatternTypeName(patternType int) string
- func FindRequestCondOperator(op string) maps.Map
- type ACMEDNSProvider
- type ACMEDNSRecord
- type ACMELocalUser
- type ACMELocalUserList
- type ACMERequest
- func (this *ACMERequest) CertDate() [2]string
- func (this *ACMERequest) CertObject() (*tls.Certificate, error)
- func (this *ACMERequest) Client() (client *lego.Client, err error)
- func (this *ACMERequest) Renew(client *lego.Client) error
- func (this *ACMERequest) Retrieve(client *lego.Client) error
- func (this *ACMERequest) RetrieveDNSRecords(client *lego.Client) (records []*ACMEDNSRecord, err error)
- func (this *ACMERequest) WriteCertFile(path string) error
- func (this *ACMERequest) WriteKeyFile(path string) error
- type ACMEUser
- type AccessLogConfig
- type AccessLogStoragePolicy
- type AccessLogStoragePolicyList
- type BackendConfig
- func (this *BackendConfig) AddRequestGroupId(requestGroupId string)
- func (this *BackendConfig) AddResponseHeader(header *shared.HeaderConfig)
- func (this *BackendConfig) CandidateCodes() []string
- func (this *BackendConfig) CandidateWeight() uint
- func (this *BackendConfig) CheckHealth() bool
- func (this *BackendConfig) CloneState(oldBackend *BackendConfig)
- func (this *BackendConfig) DecreaseConn() int32
- func (this *BackendConfig) DownCallback(callback func(backend *BackendConfig))
- func (this *BackendConfig) FailTimeoutDuration() time.Duration
- func (this *BackendConfig) HasCheckURL() bool
- func (this *BackendConfig) HasHost() bool
- func (this *BackendConfig) HasRequestGroupId(requestGroupId string) bool
- func (this *BackendConfig) HasRequestURI() bool
- func (this *BackendConfig) HasResponseHeaders() bool
- func (this *BackendConfig) IncreaseConn() int32
- func (this *BackendConfig) IncreaseFails() int32
- func (this *BackendConfig) OnAttach()
- func (this *BackendConfig) OnDetach()
- func (this *BackendConfig) OnDown()
- func (this *BackendConfig) OnUp()
- func (this *BackendConfig) ReadTimeoutDuration() time.Duration
- func (this *BackendConfig) RemoveRequestGroupId(requestGroupId string)
- func (this *BackendConfig) RequestArgs() string
- func (this *BackendConfig) RequestPath() string
- func (this *BackendConfig) RestartChecking()
- func (this *BackendConfig) StopChecking()
- func (this *BackendConfig) UpCallback(callback func(backend *BackendConfig))
- func (this *BackendConfig) Validate() error
- type BackendList
- func (this *BackendList) AddBackend(backend *BackendConfig)
- func (this *BackendList) AllBackends() []*BackendConfig
- func (this *BackendList) CloneBackendList() *BackendList
- func (this *BackendList) DeleteBackend(backendId string)
- func (this *BackendList) DeleteBackends(backendIds []string)
- func (this *BackendList) FindBackend(backendId string) *BackendConfig
- func (this *BackendList) HasBackends() bool
- func (this *BackendList) NextBackend(call *shared.RequestCall) *BackendConfig
- func (this *BackendList) SchedulingConfig() *SchedulingConfig
- func (this *BackendList) SetSchedulingConfig(scheduling *SchedulingConfig)
- func (this *BackendList) SetupScheduling(isBackup bool)
- func (this *BackendList) ValidateBackends() error
- type BackendListInterface
- type Board
- type BoardChart
- type CacheConfig
- type FastcgiConfig
- func (this *FastcgiConfig) Address() string
- func (this *FastcgiConfig) FilterParams(req *http.Request) maps.Map
- func (this *FastcgiConfig) Network() string
- func (this *FastcgiConfig) Param(paramName string) string
- func (this *FastcgiConfig) PathInfoRegexp() *regexp.Regexp
- func (this *FastcgiConfig) ReadTimeoutDuration() time.Duration
- func (this *FastcgiConfig) Validate() error
- type FastcgiList
- func (this *FastcgiList) AddFastcgi(fastcgi *FastcgiConfig)
- func (this *FastcgiList) AllFastcgi() []*FastcgiConfig
- func (this *FastcgiList) FindFastcgi(fastcgiId string) *FastcgiConfig
- func (this *FastcgiList) NextFastcgi() *FastcgiConfig
- func (this *FastcgiList) RemoveFastcgi(fastcgiId string)
- func (this *FastcgiList) ValidateFastcgi() error
- type FastcgiListInterface
- type HSTSConfig
- type IPRangeConfig
- type IPRangeList
- type IPRangeType
- type LocationConfig
- func (this *LocationConfig) AddCond(cond *RequestCond)
- func (this *LocationConfig) AddRequestGroup(group *RequestGroup)
- func (this *LocationConfig) CachePolicyObject() *shared.CachePolicy
- func (this *LocationConfig) CloneState(oldLocation *LocationConfig)
- func (this *LocationConfig) Compatible(version string)
- func (this *LocationConfig) GzipMinBytes() int64
- func (this *LocationConfig) IsCaseInsensitive() bool
- func (this *LocationConfig) IsReverse() bool
- func (this *LocationConfig) Match(path string, formatter func(source string) string) (map[string]string, bool)
- func (this *LocationConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup
- func (this *LocationConfig) MaxBodyBytes() int64
- func (this *LocationConfig) NextBackend(call *shared.RequestCall) *BackendConfig
- func (this *LocationConfig) OnAttach()
- func (this *LocationConfig) OnDetach()
- func (this *LocationConfig) PatternString() string
- func (this *LocationConfig) PatternType() int
- func (this *LocationConfig) RefersProxy(proxyId string) bool
- func (this *LocationConfig) SetPattern(pattern string, patternType int, caseInsensitive bool, reverse bool)
- func (this *LocationConfig) SetupScheduling(isBackup bool)
- func (this *LocationConfig) Validate() error
- func (this *LocationConfig) WAF() *teawaf.WAF
- type LocationPatternType
- type NodeConfig
- type NodeRole
- type PageConfig
- type RequestCond
- type RequestCondOperator
- type RequestGroup
- func (this *RequestGroup) AddCond(cond *RequestCond)
- func (this *RequestGroup) AddIPRange(ipRange *IPRangeConfig)
- func (this *RequestGroup) AddRequestHeader(header *shared.HeaderConfig)
- func (this *RequestGroup) AddResponseHeader(header *shared.HeaderConfig)
- func (this *RequestGroup) Copy() *RequestGroup
- func (this *RequestGroup) HasFilters() bool
- func (this *RequestGroup) HasRequestHeaders() bool
- func (this *RequestGroup) HasResponseHeaders() bool
- func (this *RequestGroup) Match(formatter func(source string) string) bool
- func (this *RequestGroup) Validate() error
- type RewriteList
- func (this *RewriteList) AddRewriteRule(rewrite *RewriteRule)
- func (this *RewriteList) AllRewriteRules() []*RewriteRule
- func (this *RewriteList) FindRewriteRule(rewriteId string) *RewriteRule
- func (this *RewriteList) RemoveRewriteRule(rewriteId string)
- func (this *RewriteList) ValidateRewriteRules() error
- type RewriteListInterface
- type RewriteRule
- func (this *RewriteRule) AddCond(cond *RequestCond)
- func (this *RewriteRule) AddFlag(flag string, options maps.Map)
- func (this *RewriteRule) IsExternalURL(url string) bool
- func (this *RewriteRule) Match(requestPath string, formatter func(source string) string) (replace string, varMapping map[string]string, matched bool)
- func (this *RewriteRule) RedirectMode() string
- func (this *RewriteRule) RefersProxy(proxyId string) bool
- func (this *RewriteRule) ResetFlags()
- func (this *RewriteRule) TargetProxy() string
- func (this *RewriteRule) TargetType() int
- func (this *RewriteRule) TargetURL() string
- func (this *RewriteRule) Validate() error
- type SSLCertConfig
- func (this *SSLCertConfig) CertObject() *tls.Certificate
- func (this *SSLCertConfig) DeleteFiles() error
- func (this *SSLCertConfig) FullCertPath() string
- func (this *SSLCertConfig) FullKeyPath() string
- func (this *SSLCertConfig) MatchDomain(domain string) bool
- func (this *SSLCertConfig) Validate() error
- type SSLCertTask
- type SSLConfig
- func (this *SSLConfig) AddCert(cert *SSLCertConfig)
- func (this *SSLConfig) AddCertTask(certTask *SSLCertTask)
- func (this *SSLConfig) ContainsFile(file string) bool
- func (this *SSLConfig) DeleteFiles() error
- func (this *SSLConfig) FindCert(certId string) *SSLCertConfig
- func (this *SSLConfig) FindCertTask(certTaskId string) *SSLCertTask
- func (this *SSLConfig) FirstCert() *tls.Certificate
- func (this *SSLConfig) MatchDomain(domain string) (cert *tls.Certificate, ok bool)
- func (this *SSLConfig) RemoveCertTask(certTaskId string)
- func (this *SSLConfig) TLSCipherSuites() []uint16
- func (this *SSLConfig) TLSMinVersion() uint16
- func (this *SSLConfig) Validate() error
- type SchedulingConfig
- type ServerConfig
- func (this *ServerConfig) AddListen(address string)
- func (this *ServerConfig) AddLocation(location *LocationConfig)
- func (this *ServerConfig) AddName(name ...string)
- func (this *ServerConfig) AddPage(page *PageConfig)
- func (this *ServerConfig) AddRequestGroup(group *RequestGroup)
- func (this *ServerConfig) CachePolicyObject() *shared.CachePolicy
- func (this *ServerConfig) CloneState(oldServer *ServerConfig)
- func (this *ServerConfig) Delete() error
- func (this *ServerConfig) FindBackendList(locationId string, websocket bool) (backendList BackendListInterface, err error)
- func (this *ServerConfig) FindFastcgiList(locationId string) (fastcgiList FastcgiListInterface, err error)
- func (this *ServerConfig) FindHeaderList(locationId string, backendId string, rewriteId string, fastcgiId string) (headerList shared.HeaderListInterface, err error)
- func (this *ServerConfig) FindLocation(locationId string) *LocationConfig
- func (this *ServerConfig) FindRequestGroup(groupId string) *RequestGroup
- func (this *ServerConfig) FindRewriteList(locationId string) (rewriteList RewriteListInterface, err error)
- func (this *ServerConfig) FirstName() string
- func (this *ServerConfig) GzipMinBytes() int64
- func (this *ServerConfig) IsHTTP() bool
- func (this *ServerConfig) IsTCP() bool
- func (this *ServerConfig) LocationAtIndex(index int) *LocationConfig
- func (this *ServerConfig) MatchName(name string) (matchedName string, matched bool)
- func (this *ServerConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup
- func (this *ServerConfig) MaxBodyBytes() int64
- func (this *ServerConfig) MoveLocation(fromIndex int, toIndex int)
- func (this *ServerConfig) NextBackend(call *shared.RequestCall) *BackendConfig
- func (this *ServerConfig) NextBackendIgnore(call *shared.RequestCall, backendIds []string) *BackendConfig
- func (this *ServerConfig) OnAttach()
- func (this *ServerConfig) OnDetach()
- func (this *ServerConfig) RefersProxy(proxyId string) (description string, referred bool)
- func (this *ServerConfig) RemoveLocation(locationId string)
- func (this *ServerConfig) RemoveRequestGroup(groupId string)
- func (this *ServerConfig) Save() error
- func (this *ServerConfig) SetupScheduling(isBackup bool)
- func (this *ServerConfig) Validate() error
- func (this *ServerConfig) WAF() *teawaf.WAF
- type ServerList
- type ServerNoticeConfig
- type ServerNoticeItem
- type TCPConfig
- type TLSCipherSuite
- type TLSVersion
- type TunnelConfig
- type WAFList
- type WebsocketConfig
- func (this *WebsocketConfig) AddRequestGroup(group *RequestGroup)
- func (this *WebsocketConfig) CloneState(oldWebsocket *WebsocketConfig)
- func (this *WebsocketConfig) ForwardModeSummary() maps.Map
- func (this *WebsocketConfig) HandshakeTimeoutDuration() time.Duration
- func (this *WebsocketConfig) MatchOrigin(origin string) bool
- func (this *WebsocketConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup
- func (this *WebsocketConfig) NextBackend(call *shared.RequestCall) *BackendConfig
- func (this *WebsocketConfig) SetupScheduling(isBackup bool)
- func (this *WebsocketConfig) Validate() error
- type WebsocketForwardMode
- type WildcardStatus
Constants ¶
const ( IPRangeTypeRange = IPRangeType(1) IPRangeTypeCIDR = IPRangeType(2) )
const ( LocationPatternTypePrefix = 1 LocationPatternTypeExact = 2 LocationPatternTypeRegexp = 3 )
内置的匹配类型定义
const ( NodeRoleMaster = "MASTER" NodeRoleSlave = "SLAVE" )
const ( RequestCondOperatorRegexp = "regexp" RequestCondOperatorNotRegexp = "not regexp" RequestCondOperatorGt = "gt" RequestCondOperatorGte = "gte" RequestCondOperatorLt = "lt" RequestCondOperatorLte = "lte" RequestCondOperatorEq = "eq" RequestCondOperatorNot = "not" RequestCondOperatorPrefix = "prefix" RequestCondOperatorSuffix = "suffix" RequestCondOperatorContains = "contains" RequestCondOperatorNotContains = "not contains" )
const ( RewriteTargetProxy = 1 RewriteTargetURL = 2 )
const ( RewriteFlagRedirect = "r" // 跳转,TODO: 实现 302, 305 RewriteFlagProxy = "p" // 代理 )
const ( WebsocketForwardModeWebsocket = "websocket" WebsocketForwardModeHttp = "http" )
Variables ¶
var AllTLSCipherSuites = []TLSCipherSuite{
"TLS_RSA_WITH_RC4_128_SHA",
"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_RSA_WITH_AES_128_CBC_SHA",
"TLS_RSA_WITH_AES_256_CBC_SHA",
"TLS_RSA_WITH_AES_128_CBC_SHA256",
"TLS_RSA_WITH_AES_128_GCM_SHA256",
"TLS_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_RSA_WITH_RC4_128_SHA",
"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
"TLS_AES_128_GCM_SHA256",
"TLS_AES_256_GCM_SHA384",
"TLS_CHACHA20_POLY1305_SHA256",
}
var AllTlsVersions = []TLSVersion{"SSL 3.0", "TLS 1.0", "TLS 1.1", "TLS 1.2", "TLS 1.3"}
var RegexpDigitNumber = regexp.MustCompile("^\\d+$")
var RegexpDigitVariable = regexp.MustCompile("\\${\\d+}")
var RegexpExternalURL = regexp.MustCompile("(?i)^(http|https|ftp)://")
var RegexpNamedVariable = regexp.MustCompile("\\${[\\w.-]+}")
var TLSIntermediateCipherSuites = []string{
"TLS_AES_128_GCM_SHA256",
"TLS_CHACHA20_POLY1305_SHA256",
"TLS_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
}
var TLSModernCipherSuites = []string{
"TLS_AES_128_GCM_SHA256",
"TLS_CHACHA20_POLY1305_SHA256",
"TLS_AES_256_GCM_SHA384",
"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
}
Functions ¶
func FindLocationPatternTypeName ¶
查找单个匹配类型名称
func FindRequestCondOperator ¶ added in v0.1.2
查找某个运算符信息
Types ¶
type ACMEDNSProvider ¶ added in v0.1.5
type ACMEDNSProvider struct {
// contains filtered or unexported fields
}
自定义ACME DNS解析
func NewACMEDNSProvider ¶ added in v0.1.5
func NewACMEDNSProvider(apiAuthToken string) *ACMEDNSProvider
func (*ACMEDNSProvider) CleanUp ¶ added in v0.1.5
func (this *ACMEDNSProvider) CleanUp(domain, token, keyAuth string) error
func (*ACMEDNSProvider) Present ¶ added in v0.1.5
func (this *ACMEDNSProvider) Present(domain, token, keyAuth string) error
type ACMEDNSRecord ¶ added in v0.1.5
type ACMEDNSRecord struct { FQDN string `yaml:"fqdn" json:"fqdn"` Value string `yaml:"value" json:"value"` }
ACME DNS记录
type ACMELocalUser ¶ added in v0.1.5
type ACMELocalUser struct { Id string `yaml:"id" json:"id"` Name string `yaml:"name" json:"name"` On bool `yaml:"on" json:"on"` Email string `yaml:"email" json:"email"` Key string `yaml:"key" json:"key"` // base64 URI string `yaml:"uri" json:"uri"` }
本地用户信息
type ACMELocalUserList ¶ added in v0.1.5
type ACMELocalUserList struct {
Users []*ACMELocalUser `yaml:"users" json:"users"`
}
本地用户列表
func SharedACMELocalUserList ¶ added in v0.1.5
func SharedACMELocalUserList() *ACMELocalUserList
取得共享的本地用户列表
func (*ACMELocalUserList) AddUser ¶ added in v0.1.5
func (this *ACMELocalUserList) AddUser(user *ACMELocalUser)
添加用户
func (*ACMELocalUserList) FindUser ¶ added in v0.1.5
func (this *ACMELocalUserList) FindUser(userId string) *ACMELocalUser
查找用户
func (*ACMELocalUserList) RemoveUser ¶ added in v0.1.5
func (this *ACMELocalUserList) RemoveUser(userId string)
删除用户
type ACMERequest ¶ added in v0.1.5
type ACMERequest struct { User *ACMELocalUser `yaml:"user" json:"user"` Domains []string `yaml:"domains" json:"domains"` DNSRecords []*ACMEDNSRecord `yaml:"dnsRecords" json:"dnsRecords"` CertURL string `yaml:"certURL" json:"certURL"` Cert string `yaml:"cert" json:"cert"` Key string `yaml:"key" json:"key"` }
ACME DNS Request
func (*ACMERequest) CertObject ¶ added in v0.1.5
func (this *ACMERequest) CertObject() (*tls.Certificate, error)
获取证书对象
func (*ACMERequest) Client ¶ added in v0.1.5
func (this *ACMERequest) Client() (client *lego.Client, err error)
获取连接客户端
func (*ACMERequest) Renew ¶ added in v0.1.5
func (this *ACMERequest) Renew(client *lego.Client) error
更新
func (*ACMERequest) Retrieve ¶ added in v0.1.5
func (this *ACMERequest) Retrieve(client *lego.Client) error
获取证书信息
func (*ACMERequest) RetrieveDNSRecords ¶ added in v0.1.5
func (this *ACMERequest) RetrieveDNSRecords(client *lego.Client) (records []*ACMEDNSRecord, err error)
获取要设置的DNS记录
func (*ACMERequest) WriteCertFile ¶ added in v0.1.5
func (this *ACMERequest) WriteCertFile(path string) error
写入证书文件
func (*ACMERequest) WriteKeyFile ¶ added in v0.1.5
func (this *ACMERequest) WriteKeyFile(path string) error
写入密钥文件
type ACMEUser ¶ added in v0.1.5
type ACMEUser struct { Email string Registration *registration.Resource Key crypto.PrivateKey }
ACME用户账号定义
func (*ACMEUser) GetPrivateKey ¶ added in v0.1.5
func (this *ACMEUser) GetPrivateKey() crypto.PrivateKey
func (*ACMEUser) GetRegistration ¶ added in v0.1.5
func (this *ACMEUser) GetRegistration() *registration.Resource
type AccessLogConfig ¶
type AccessLogConfig struct { Id string `yaml:"id" json:"id"` On bool `yaml:"on" json:"on"` Fields []int `yaml:"fields" json:"fields"` // 记录的字段 Status1 bool `yaml:"status1" json:"status1"` // 1xx Status2 bool `yaml:"status2" json:"status2"` // 2xx Status3 bool `yaml:"status3" json:"status3"` // 3xx Status4 bool `yaml:"status4" json:"status4"` // 4xx Status5 bool `yaml:"status5" json:"status5"` // 5xx StorageOnly bool `yaml:"storageOnly" json:"storageOnly"` // 是否只输出到存储策略 StoragePolicies []string `yaml:"storagePolicies" json:"storagePolicies"` // 存储策略Ids }
代理访问日志配置
func (*AccessLogConfig) ContainsStoragePolicy ¶ added in v0.1.6
func (this *AccessLogConfig) ContainsStoragePolicy(storagePolicyId string) bool
是否包含某个存储策略
func (*AccessLogConfig) Match ¶ added in v0.1.5
func (this *AccessLogConfig) Match(status int) bool
判断是否应该记录
type AccessLogStoragePolicy ¶ added in v0.1.6
type AccessLogStoragePolicy struct { Id string `yaml:"id" json:"id"` Name string `yaml:"name" json:"name"` On bool `yaml:"bool" json:"on"` Type string `yaml:"type" json:"type"` Options map[string]interface{} `yaml:"options" json:"options"` // 存储选项 }
日志存储策略 存储在configs/accesslog.storage.$id.conf
func NewAccessLogStoragePolicy ¶ added in v0.1.6
func NewAccessLogStoragePolicy() *AccessLogStoragePolicy
创建新策略
func NewAccessLogStoragePolicyFromId ¶ added in v0.1.6
func NewAccessLogStoragePolicyFromId(id string) *AccessLogStoragePolicy
从文件中加载策略
func (*AccessLogStoragePolicy) Delete ¶ added in v0.1.6
func (this *AccessLogStoragePolicy) Delete() error
删除
func (*AccessLogStoragePolicy) Save ¶ added in v0.1.6
func (this *AccessLogStoragePolicy) Save() error
保存
type AccessLogStoragePolicyList ¶ added in v0.1.6
type AccessLogStoragePolicyList struct {
Ids []string `yaml:"id" json:"id"`
}
存储策略列表
func SharedAccessLogStoragePolicyList ¶ added in v0.1.6
func SharedAccessLogStoragePolicyList() *AccessLogStoragePolicyList
获取共享的存储策略列表
func (*AccessLogStoragePolicyList) AddId ¶ added in v0.1.6
func (this *AccessLogStoragePolicyList) AddId(id string)
添加策略ID
func (*AccessLogStoragePolicyList) FindAllPolicies ¶ added in v0.1.6
func (this *AccessLogStoragePolicyList) FindAllPolicies() []*AccessLogStoragePolicy
查找所有的策略列表
func (*AccessLogStoragePolicyList) RemoveId ¶ added in v0.1.6
func (this *AccessLogStoragePolicyList) RemoveId(id string)
删除策略ID
func (*AccessLogStoragePolicyList) Save ¶ added in v0.1.6
func (this *AccessLogStoragePolicyList) Save() error
保存
type BackendConfig ¶
type BackendConfig struct { shared.HeaderList `yaml:",inline"` On bool `yaml:"on" json:"on"` // 是否启用 Id string `yaml:"id" json:"id"` // ID Code string `yaml:"code" json:"code"` // 代号 Address string `yaml:"address" json:"address"` // 地址 Scheme string `yaml:"scheme" json:"scheme"` // 协议,http、https、tcp、tcp+tls Weight uint `yaml:"weight" json:"weight"` // 权重 IsBackup bool `yaml:"backup" json:"isBackup"` // 是否为备份 FailTimeout string `yaml:"failTimeout" json:"failTimeout"` // 连接失败超时 ReadTimeout string `yaml:"readTimeout" json:"readTimeout"` // 读取超时时间 MaxFails int32 `yaml:"maxFails" json:"maxFails"` // 最多失败次数 CurrentFails int32 `yaml:"currentFails" json:"currentFails"` // 当前已失败次数 MaxConns int32 `yaml:"maxConns" json:"maxConns"` // 最大并发连接数 CurrentConns int32 `yaml:"currentConns" json:"currentConns"` // 当前连接数 IsDown bool `yaml:"down" json:"isDown"` // 是否下线 DownTime time.Time `yaml:"downTime,omitempty" json:"downTime,omitempty"` // 下线时间 RequestGroupIds []string `yaml:"requestGroupIds" json:"requestGroupIds"` // 所属请求分组 RequestURI string `yaml:"requestURI" json:"requestURI"` // 转发后的请求URI ResponseHeaders []*shared.HeaderConfig `yaml:"responseHeaders" json:"responseHeaders"` // 响应Header Host string `yaml:"host" json:"host"` // 自定义主机名 // 健康检查URL,目前支持: // - http|https 返回2xx-3xx认为成功 CheckURL string `yaml:"checkURL" json:"checkURL"` CheckInterval int `yaml:"checkInterval" json:"checkInterval"` // contains filtered or unexported fields }
服务后端配置
func (*BackendConfig) AddRequestGroupId ¶ added in v0.1.2
func (this *BackendConfig) AddRequestGroupId(requestGroupId string)
添加请求分组
func (*BackendConfig) AddResponseHeader ¶ added in v0.1.2
func (this *BackendConfig) AddResponseHeader(header *shared.HeaderConfig)
添加响应Header
func (*BackendConfig) CheckHealth ¶ added in v0.1.2
func (this *BackendConfig) CheckHealth() bool
健康检查
func (*BackendConfig) CloneState ¶ added in v0.1.6
func (this *BackendConfig) CloneState(oldBackend *BackendConfig)
克隆状态
func (*BackendConfig) DecreaseConn ¶
func (this *BackendConfig) DecreaseConn() int32
减少连接数,并返回减少之后的数字
func (*BackendConfig) DownCallback ¶ added in v0.1.2
func (this *BackendConfig) DownCallback(callback func(backend *BackendConfig))
增加下线回调
func (*BackendConfig) FailTimeoutDuration ¶
func (this *BackendConfig) FailTimeoutDuration() time.Duration
连接超时时间
func (*BackendConfig) HasCheckURL ¶ added in v0.1.2
func (this *BackendConfig) HasCheckURL() bool
判断是否有URL Check
func (*BackendConfig) HasHost ¶ added in v0.1.3
func (this *BackendConfig) HasHost() bool
判断是否有自定义主机名
func (*BackendConfig) HasRequestGroupId ¶ added in v0.1.2
func (this *BackendConfig) HasRequestGroupId(requestGroupId string) bool
判断是否有某个情趣分组ID
func (*BackendConfig) HasRequestURI ¶ added in v0.1.2
func (this *BackendConfig) HasRequestURI() bool
判断是否设置RequestURI
func (*BackendConfig) HasResponseHeaders ¶ added in v0.1.2
func (this *BackendConfig) HasResponseHeaders() bool
判断是否有响应Header
func (*BackendConfig) IncreaseConn ¶
func (this *BackendConfig) IncreaseConn() int32
增加连接数,并返回增加之后的数字
func (*BackendConfig) ReadTimeoutDuration ¶
func (this *BackendConfig) ReadTimeoutDuration() time.Duration
读取超时时间
func (*BackendConfig) RemoveRequestGroupId ¶ added in v0.1.2
func (this *BackendConfig) RemoveRequestGroupId(requestGroupId string)
删除某个请求分组
func (*BackendConfig) RequestArgs ¶ added in v0.1.2
func (this *BackendConfig) RequestArgs() string
获取转发后的附加参数
func (*BackendConfig) RequestPath ¶ added in v0.1.2
func (this *BackendConfig) RequestPath() string
获取转发后的Path
func (*BackendConfig) RestartChecking ¶ added in v0.1.2
func (this *BackendConfig) RestartChecking()
重启检查
func (*BackendConfig) StopChecking ¶ added in v0.1.2
func (this *BackendConfig) StopChecking()
停止Checking
func (*BackendConfig) UpCallback ¶ added in v0.1.2
func (this *BackendConfig) UpCallback(callback func(backend *BackendConfig))
增加上线回调
type BackendList ¶
type BackendList struct { Backends []*BackendConfig `yaml:"backends" json:"backends"` Scheduling *SchedulingConfig `yaml:"scheduling" json:"scheduling"` // 调度算法选项 // contains filtered or unexported fields }
BackendList定义
func (*BackendList) AddBackend ¶
func (this *BackendList) AddBackend(backend *BackendConfig)
添加Backend
func (*BackendList) AllBackends ¶
func (this *BackendList) AllBackends() []*BackendConfig
所有的Backends
func (*BackendList) CloneBackendList ¶ added in v0.1.6
func (this *BackendList) CloneBackendList() *BackendList
克隆
func (*BackendList) DeleteBackend ¶
func (this *BackendList) DeleteBackend(backendId string)
删除后端服务器
func (*BackendList) DeleteBackends ¶ added in v0.1.6
func (this *BackendList) DeleteBackends(backendIds []string)
删除一组后端服务器
func (*BackendList) FindBackend ¶
func (this *BackendList) FindBackend(backendId string) *BackendConfig
根据ID查找后端服务器
func (*BackendList) HasBackends ¶ added in v0.1.2
func (this *BackendList) HasBackends() bool
判断是否有后端服务器
func (*BackendList) NextBackend ¶
func (this *BackendList) NextBackend(call *shared.RequestCall) *BackendConfig
取得下一个可用的后端服务
func (*BackendList) SchedulingConfig ¶
func (this *BackendList) SchedulingConfig() *SchedulingConfig
调度算法
func (*BackendList) SetSchedulingConfig ¶
func (this *BackendList) SetSchedulingConfig(scheduling *SchedulingConfig)
设置调度算法
func (*BackendList) SetupScheduling ¶
func (this *BackendList) SetupScheduling(isBackup bool)
设置调度算法
type BackendListInterface ¶
type BackendListInterface interface { // 校验 ValidateBackends() error // 添加Backend AddBackend(backend *BackendConfig) // 所有的Backends AllBackends() []*BackendConfig // 删除后端服务器 DeleteBackend(backendId string) // 查找后端服务器 FindBackend(backendId string) *BackendConfig // 调度算法 SchedulingConfig() *SchedulingConfig // 设置调度算法 SetSchedulingConfig(scheduling *SchedulingConfig) }
BackendList接口定义
type BoardChart ¶
type BoardChart struct { WidgetId string `yaml:"widgetId" json:"widgetId"` ChartId string `yaml:"chartId" json:"chartId"` }
看板图表
type CacheConfig ¶
type CacheConfig struct { Filename string `yaml:"filename" json:"filename"` // 文件名 PolicyFiles []string `yaml:"policyFiles" json:"policyFiles"` // 策略文件 }
缓存管理
func (*CacheConfig) FindAllPolicies ¶
func (this *CacheConfig) FindAllPolicies() []*shared.CachePolicy
查找所有的缓存策略
type FastcgiConfig ¶
type FastcgiConfig struct { shared.HeaderList `yaml:",inline"` On bool `yaml:"on" json:"on"` Id string `yaml:"id" json:"id"` // fastcgi地址配置 // 支持unix:/tmp/php-fpm.sock ... Pass string `yaml:"pass" json:"pass"` Index string `yaml:"index" json:"index"` //@TODO Params map[string]string `yaml:"params" json:"params"` //@TODO ReadTimeout string `yaml:"readTimeout" json:"readTimeout"` // @TODO 读取超时时间 SendTimeout string `yaml:"sendTimeout" json:"sendTimeout"` // @TODO 发送超时时间 ConnTimeout string `yaml:"connTimeout" json:"connTimeout"` // @TODO 连接超时时间 PoolSize int `yaml:"poolSize" json:"poolSize"` // 连接池尺寸 PathInfoPattern string `yaml:"pathInfoPattern" json:"pathInfoPattern"` // PATH_INFO匹配正则 // contains filtered or unexported fields }
Fastcgi配置
func (*FastcgiConfig) FilterParams ¶
func (this *FastcgiConfig) FilterParams(req *http.Request) maps.Map
过滤参数
func (*FastcgiConfig) PathInfoRegexp ¶ added in v0.1.2
func (this *FastcgiConfig) PathInfoRegexp() *regexp.Regexp
PATH_INFO正则
func (*FastcgiConfig) ReadTimeoutDuration ¶
func (this *FastcgiConfig) ReadTimeoutDuration() time.Duration
超时时间
type FastcgiList ¶
type FastcgiList struct {
Fastcgi []*FastcgiConfig `yaml:"fastcgi" json:"fastcgi"`
}
FastcgiList定义
func (*FastcgiList) AddFastcgi ¶
func (this *FastcgiList) AddFastcgi(fastcgi *FastcgiConfig)
添加Fastcgi
func (*FastcgiList) AllFastcgi ¶
func (this *FastcgiList) AllFastcgi() []*FastcgiConfig
取得所有的Fastcgi
func (*FastcgiList) FindFastcgi ¶
func (this *FastcgiList) FindFastcgi(fastcgiId string) *FastcgiConfig
根据ID查找Fastcgi
func (*FastcgiList) NextFastcgi ¶
func (this *FastcgiList) NextFastcgi() *FastcgiConfig
查找下一个可用的Fastcgi
func (*FastcgiList) RemoveFastcgi ¶
func (this *FastcgiList) RemoveFastcgi(fastcgiId string)
删除Fastcgi
type FastcgiListInterface ¶
type FastcgiListInterface interface { // 校验 ValidateFastcgi() error // 取得所有的Fastcgi AllFastcgi() []*FastcgiConfig // 根据ID查找Fastcgi FindFastcgi(fastcgiId string) *FastcgiConfig // 添加Fastcgi AddFastcgi(fastcgi *FastcgiConfig) // 删除Fastcgi RemoveFastcgi(fastcgiId string) // 查找下一个可用的Fastcgi NextFastcgi() *FastcgiConfig }
FastcgiList接口定义
type HSTSConfig ¶ added in v0.1.5
type HSTSConfig struct { On bool `yaml:"on" json:"on"` MaxAge int `yaml:"maxAge" json:"maxAge"` // 单位秒 IncludeSubDomains bool `yaml:"includeSubDomains" json:"includeSubDomains"` Preload bool `yaml:"preload" json:"preload"` Domains []string `yaml:"domains" json:"domains"` // contains filtered or unexported fields }
HSTS设置 参考: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
func (*HSTSConfig) HeaderKey ¶ added in v0.1.5
func (this *HSTSConfig) HeaderKey() string
Header Key
func (*HSTSConfig) HeaderValue ¶ added in v0.1.5
func (this *HSTSConfig) HeaderValue() string
取得当前的Header值
func (*HSTSConfig) Match ¶ added in v0.1.5
func (this *HSTSConfig) Match(domain string) bool
判断是否匹配域名
type IPRangeConfig ¶ added in v0.1.2
type IPRangeConfig struct { Id string `yaml:"id" json:"id"` Type IPRangeType `yaml:"type" json:"type"` Param string `yaml:"param" json:"param"` CIDR string `yaml:"cidr" json:"cidr"` IPFrom string `yaml:"ipFrom" json:"ipFrom"` IPTo string `yaml:"ipTo" json:"ipTo"` // contains filtered or unexported fields }
IP Range
func (*IPRangeConfig) Contains ¶ added in v0.1.2
func (this *IPRangeConfig) Contains(ipString string) bool
是否包含某个IP
type IPRangeList ¶ added in v0.1.2
type IPRangeList struct {
IPRanges []*IPRangeConfig
}
IP Range列表
func (*IPRangeList) AddIPRange ¶ added in v0.1.2
func (this *IPRangeList) AddIPRange(ipRange *IPRangeConfig)
添加
func (*IPRangeList) RemoveIPRange ¶ added in v0.1.2
func (this *IPRangeList) RemoveIPRange(ipRangeId string)
删除
type LocationConfig ¶
type LocationConfig struct { shared.HeaderList `yaml:",inline"` FastcgiList `yaml:",inline"` RewriteList `yaml:",inline"` BackendList `yaml:",inline"` On bool `yaml:"on" json:"on"` // 是否开启 Id string `yaml:"id" json:"id"` // ID Name string `yaml:"name" json:"name"` // 名称 Pattern string `yaml:"pattern" json:"pattern"` // 匹配规则 Async bool `yaml:"async" json:"async"` // 是否异步请求 @TODO Notify []interface{} `yaml:"notify" json:"notify"` // 转发请求,可以配置转发策略 @TODO LogOnly bool `yaml:"logOnly" json:"logOnly"` // 是否只记录日志 @TODO Root string `yaml:"root" json:"root"` // 资源根目录 Index []string `yaml:"index" json:"index"` // 默认文件 Charset string `yaml:"charset" json:"charset"` // 字符集设置 MaxBodySize string `yaml:"maxBodySize" json:"maxBodySize"` // 请求body最大尺寸 GzipLevel int8 `yaml:"gzipLevel" json:"gzipLevel"` // Gzip压缩级别 GzipMinLength string `yaml:"gzipMinLength" json:"gzipMinLength"` // 需要压缩的最小内容尺寸 AccessPolicy *shared.AccessPolicy `yaml:"accessPolicy" json:"accessPolicy"` // 访问控制 RedirectToHttps bool `yaml:"redirectToHttps" json:"redirectToHttps"` // 是否自动跳转到Https // 日志 AccessLog []*AccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志设置,如果为空表示继承上一级设置 DisableAccessLog1 bool `yaml:"disableAccessLog" json:"disableAccessLog"` // deprecated: 是否禁用访问日志 AccessLogFields1 []int `yaml:"accessLogFields" json:"accessLogFields"` // deprecated: 访问日志保留的字段,如果为nil,则表示没有设置 DisableStat bool `yaml:"disableStat" json:"disableStat"` // 是否禁用统计 // 参考:http://nginx.org/en/docs/http/ngx_http_access_module.html Allow []string `yaml:"allow" json:"allow"` // 允许的终端地址 @TODO Deny []string `yaml:"deny" json:"deny"` // 禁止的终端地址 @TODO Proxy string `yaml:"proxy" json:"proxy"` // 代理配置 @TODO CachePolicy string `yaml:"cachePolicy" json:"cachePolicy"` // 缓存策略 CacheOn bool `yaml:"cacheOn" json:"cacheOn"` // 缓存是否打开 WAFOn bool `yaml:"wafOn" json:"wafOn"` // 是否启用 WafId string `yaml:"wafId" json:"wafId"` // WAF ID // websocket设置 Websocket *WebsocketConfig `yaml:"websocket" json:"websocket"` // 开启的条件 // 语法为:cond param operator value 比如: // - cond ${status} gte 200 // - cond ${arg.name} eq lily // - cond ${requestPath} regexp .*\.png Cond []*RequestCond `yaml:"cond" json:"cond"` // contains filtered or unexported fields }
路径配置
func (*LocationConfig) AddCond ¶ added in v0.1.2
func (this *LocationConfig) AddCond(cond *RequestCond)
添加过滤条件
func (*LocationConfig) AddRequestGroup ¶ added in v0.1.2
func (this *LocationConfig) AddRequestGroup(group *RequestGroup)
添加请求分组
func (*LocationConfig) CachePolicyObject ¶
func (this *LocationConfig) CachePolicyObject() *shared.CachePolicy
缓存策略
func (*LocationConfig) CloneState ¶ added in v0.1.6
func (this *LocationConfig) CloneState(oldLocation *LocationConfig)
克隆运行时状态
func (*LocationConfig) Compatible ¶ added in v0.1.5
func (this *LocationConfig) Compatible(version string)
兼容性设置
func (*LocationConfig) IsCaseInsensitive ¶
func (this *LocationConfig) IsCaseInsensitive() bool
是否大小写非敏感
func (*LocationConfig) Match ¶
func (this *LocationConfig) Match(path string, formatter func(source string) string) (map[string]string, bool)
判断是否匹配路径
func (*LocationConfig) MatchRequestGroup ¶ added in v0.1.2
func (this *LocationConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup
使用请求匹配分组
func (*LocationConfig) NextBackend ¶ added in v0.1.2
func (this *LocationConfig) NextBackend(call *shared.RequestCall) *BackendConfig
取得下一个可用的后端服务
func (*LocationConfig) PatternString ¶
func (this *LocationConfig) PatternString() string
模式字符串 去掉了模式字符
func (*LocationConfig) RefersProxy ¶ added in v0.1.2
func (this *LocationConfig) RefersProxy(proxyId string) bool
是否在引用某个代理
func (*LocationConfig) SetPattern ¶
func (this *LocationConfig) SetPattern(pattern string, patternType int, caseInsensitive bool, reverse bool)
组合参数为一个字符串
func (*LocationConfig) SetupScheduling ¶ added in v0.1.2
func (this *LocationConfig) SetupScheduling(isBackup bool)
设置调度算法
type NodeConfig ¶ added in v0.1.4
type NodeConfig struct { Id string `yaml:"id" json:"id"` // ID On bool `yaml:"on" json:"on"` // 是否启用 Name string `yaml:"name" json:"name"` // 名称 ClusterId string `yaml:"clusterId" json:"clusterId"` // 集群ID ClusterSecret string `yaml:"clusterSecret" json:"clusterSecret"` // 集群秘钥 ClusterAddr string `yaml:"clusterAddr" json:"clusterAddr"` // 集群通讯地址 Role NodeRole `yaml:"role" json:"role"` // 角色 }
节点配置
func SharedNodeConfig ¶ added in v0.1.4
func SharedNodeConfig() *NodeConfig
取得当前节点配置 如果为nil,表示尚未配置集群
type PageConfig ¶ added in v0.1.2
type PageConfig struct { On bool `yaml:"on" json:"on"` // TODO Status []string `yaml:"status" json:"status"` // 支持40x, 50x, 3x2 URL string `yaml:"url" json:"url"` // contains filtered or unexported fields }
特殊页面配置
type RequestCond ¶ added in v0.1.2
type RequestCond struct { Id string `yaml:"id" json:"id"` // ID // 要测试的字符串 // 其中可以使用跟请求相关的参数,比如: // ${arg.name}, ${requestPath} Param string `yaml:"param" json:"param"` // 运算符 Operator RequestCondOperator `yaml:"operator" json:"operator"` // 对比 Value string `yaml:"value" json:"value"` // contains filtered or unexported fields }
重写条件定义
func (*RequestCond) Match ¶ added in v0.1.2
func (this *RequestCond) Match(formatter func(source string) string) bool
将此条件应用于请求,检查是否匹配
type RequestGroup ¶ added in v0.1.2
type RequestGroup struct { BackendList `yaml:",inline"` Id string `yaml:"id" json:"id"` // ID Name string `yaml:"name" json:"name"` // 名称 Cond []*RequestCond `yaml:"conds" json:"conds"` // 匹配条件 IPRanges []*IPRangeConfig `yaml:"ipRanges" json:"ipRanges"` // IP范围 IsDefault bool `yaml:"isDefault" json:"isDefault"` // 是否为默认分组 RequestHeaders []*shared.HeaderConfig `yaml:"requestHeaders" json:"requestHeaders"` // 请求Header ResponseHeaders []*shared.HeaderConfig `yaml:"responseHeaders" json:"responseHeaders"` // 响应Header // contains filtered or unexported fields }
请求条件分组
func (*RequestGroup) AddCond ¶ added in v0.1.2
func (this *RequestGroup) AddCond(cond *RequestCond)
添加匹配条件
func (*RequestGroup) AddIPRange ¶ added in v0.1.2
func (this *RequestGroup) AddIPRange(ipRange *IPRangeConfig)
添加IP范围
func (*RequestGroup) AddRequestHeader ¶ added in v0.1.2
func (this *RequestGroup) AddRequestHeader(header *shared.HeaderConfig)
添加请求Header
func (*RequestGroup) AddResponseHeader ¶ added in v0.1.2
func (this *RequestGroup) AddResponseHeader(header *shared.HeaderConfig)
添加响应Header
func (*RequestGroup) HasFilters ¶ added in v0.1.2
func (this *RequestGroup) HasFilters() bool
判断是否有过滤条件
func (*RequestGroup) HasRequestHeaders ¶ added in v0.1.2
func (this *RequestGroup) HasRequestHeaders() bool
判断是否有请求Header
func (*RequestGroup) HasResponseHeaders ¶ added in v0.1.2
func (this *RequestGroup) HasResponseHeaders() bool
判断是否有响应Header
func (*RequestGroup) Match ¶ added in v0.1.2
func (this *RequestGroup) Match(formatter func(source string) string) bool
判断匹配
type RewriteList ¶
type RewriteList struct {
Rewrite []*RewriteRule `yaml:"rewrite" json:"rewrite"`
}
RewriteList定义
func (*RewriteList) AddRewriteRule ¶
func (this *RewriteList) AddRewriteRule(rewrite *RewriteRule)
添加Rewrite
func (*RewriteList) AllRewriteRules ¶
func (this *RewriteList) AllRewriteRules() []*RewriteRule
取得所有的Rewrite
func (*RewriteList) FindRewriteRule ¶
func (this *RewriteList) FindRewriteRule(rewriteId string) *RewriteRule
根据ID查找Rewrite
func (*RewriteList) RemoveRewriteRule ¶
func (this *RewriteList) RemoveRewriteRule(rewriteId string)
删除Rewrite
type RewriteListInterface ¶
type RewriteListInterface interface { // 校验 ValidateRewriteRules() error // 取得所有的Rewrite AllRewriteRules() []*RewriteRule // 根据ID查找Rewrite FindRewriteRule(rewriteId string) *RewriteRule // 添加Rewrite AddRewriteRule(rewrite *RewriteRule) // 删除Rewrite RemoveRewriteRule(rewriteId string) }
RewriteList接口
type RewriteRule ¶
type RewriteRule struct { shared.HeaderList `yaml:",inline"` On bool `yaml:"on" json:"on"` // 是否开启 Id string `yaml:"id" json:"id"` // ID // 开启的条件 // 语法为:cond param operator value 比如: // - cond ${status} gte 200 // - cond ${arg.name} eq lily // - cond ${requestPath} regexp .*\.png Cond []*RequestCond `yaml:"cond" json:"cond"` // 规则 // 语法为:pattern regexp 比如: // - pattern ^/article/(\d+).html Pattern string `yaml:"pattern" json:"pattern"` // 要替换成的URL // 支持反向引用:${0}, ${1}, ...,也支持?P<NAME>语法 // - 如果以 proxy:// 开头,表示目标为代理,首先会尝试作为代理ID请求,如果找不到,会尝试作为代理Host请求 Replace string `yaml:"replace" json:"replace"` // 选项 Flags []string `yaml:"flags" json:"flags"` FlagOptions maps.Map `yaml:"flagOptions" json:"flagOptions"` // flag => options map // contains filtered or unexported fields }
重写规则定义
参考 - http://nginx.org/en/docs/http/ngx_http_rewrite_module.html - https://httpd.apache.org/docs/current/mod/mod_rewrite.html - https://httpd.apache.org/docs/2.4/rewrite/flags.html
func (*RewriteRule) AddFlag ¶
func (this *RewriteRule) AddFlag(flag string, options maps.Map)
添加Flag
func (*RewriteRule) IsExternalURL ¶
func (this *RewriteRule) IsExternalURL(url string) bool
判断是否是外部URL
func (*RewriteRule) Match ¶
func (this *RewriteRule) Match(requestPath string, formatter func(source string) string) (replace string, varMapping map[string]string, matched bool)
对某个请求执行规则
func (*RewriteRule) RefersProxy ¶ added in v0.1.2
func (this *RewriteRule) RefersProxy(proxyId string) bool
是否在引用某个代理
type SSLCertConfig ¶ added in v0.1.4
type SSLCertConfig struct { Id string `yaml:"id" json:"id"` On bool `yaml:"on" json:"on"` Description string `yaml:"description" json:"description"` CertFile string `yaml:"certFile" json:"certFile"` KeyFile string `yaml:"keyFile" json:"keyFile"` IsLocal bool `yaml:"isLocal" json:"isLocal"` // if is local file TaskId string `yaml:"taskId" json:"taskId"` // 生成证书任务ID // contains filtered or unexported fields }
SSL证书
func NewSSLCertConfig ¶ added in v0.1.4
func NewSSLCertConfig(certFile string, keyFile string) *SSLCertConfig
获取新的SSL证书
func (*SSLCertConfig) CertObject ¶ added in v0.1.4
func (this *SSLCertConfig) CertObject() *tls.Certificate
获取证书对象
func (*SSLCertConfig) DeleteFiles ¶ added in v0.1.4
func (this *SSLCertConfig) DeleteFiles() error
删除文件
func (*SSLCertConfig) FullCertPath ¶ added in v0.1.4
func (this *SSLCertConfig) FullCertPath() string
证书文件路径
func (*SSLCertConfig) FullKeyPath ¶ added in v0.1.4
func (this *SSLCertConfig) FullKeyPath() string
密钥文件路径
func (*SSLCertConfig) MatchDomain ¶ added in v0.1.4
func (this *SSLCertConfig) MatchDomain(domain string) bool
校验是否匹配某个域名
type SSLCertTask ¶ added in v0.1.5
type SSLCertTask struct { Id string `yaml:"id" json:"id"` // ID On bool `yaml:"on" json:"on"` // 是否启用 RunAt int64 `yaml:"runAt" json:"runAt"` // 运行时间 RunError string `yaml:"runError" json:"runError"` // 运行错误 Request *ACMERequest `yaml:"request" json:"request"` // ACME信息 }
证书生成任务
type SSLConfig ¶
type SSLConfig struct { On bool `yaml:"on" json:"on"` // 是否开启 Certificate string `yaml:"certificate" json:"certificate"` // 证书文件, deprecated in v0.1.4 CertificateKey string `yaml:"certificateKey" json:"certificateKey"` // 密钥, deprecated in v0.1.4 Certs []*SSLCertConfig `yaml:"certs" json:"certs"` CertTasks []*SSLCertTask `yaml:"certTasks" json:"certTasks"` Listen []string `yaml:"listen" json:"listen"` // 网络地址 MinVersion TLSVersion `yaml:"minVersion" json:"minVersion"` // 支持的最小版本 CipherSuites []TLSCipherSuite `yaml:"cipherSuites" json:"cipherSuites"` // 加密算法套件 HSTS *HSTSConfig `yaml:"hsts2" json:"hsts"` // HSTS配置,yaml之所以使用hsts2,是因为要和以前的版本分开 // contains filtered or unexported fields }
SSL配置
func (*SSLConfig) AddCert ¶ added in v0.1.5
func (this *SSLConfig) AddCert(cert *SSLCertConfig)
添加证书
func (*SSLConfig) AddCertTask ¶ added in v0.1.5
func (this *SSLConfig) AddCertTask(certTask *SSLCertTask)
添加证书任务
func (*SSLConfig) ContainsFile ¶ added in v0.1.4
是否包含某个证书或密钥路径
func (*SSLConfig) FindCert ¶ added in v0.1.4
func (this *SSLConfig) FindCert(certId string) *SSLCertConfig
查找单个证书配置
func (*SSLConfig) FindCertTask ¶ added in v0.1.5
func (this *SSLConfig) FindCertTask(certTaskId string) *SSLCertTask
查找证书任务
func (*SSLConfig) FirstCert ¶ added in v0.1.4
func (this *SSLConfig) FirstCert() *tls.Certificate
取得第一个证书
func (*SSLConfig) MatchDomain ¶ added in v0.1.3
func (this *SSLConfig) MatchDomain(domain string) (cert *tls.Certificate, ok bool)
校验是否匹配某个域名
func (*SSLConfig) RemoveCertTask ¶ added in v0.1.5
删除证书任务
func (*SSLConfig) TLSCipherSuites ¶ added in v0.1.3
套件
func (*SSLConfig) TLSMinVersion ¶ added in v0.1.3
取得最小版本
type SchedulingConfig ¶
type SchedulingConfig struct { Code string `yaml:"code" json:"code"` // 类型 Options maps.Map `yaml:"options" json:"options"` // 选项 }
调度算法配置
type ServerConfig ¶
type ServerConfig struct { shared.HeaderList `yaml:",inline"` FastcgiList `yaml:",inline"` RewriteList `yaml:",inline"` BackendList `yaml:",inline"` On bool `yaml:"on" json:"on"` Id string `yaml:"id" json:"id"` // ID TeaVersion string `yaml:"teaVersion" json:"teaVersion"` // Tea版本 Description string `yaml:"description" json:"description"` // 描述 Name []string `yaml:"name" json:"name"` // 域名 Http bool `yaml:"http" json:"http"` // 是否支持HTTP RedirectToHttps bool `yaml:"redirectToHttps" json:"redirectToHttps"` // 是否自动跳转到Https IsDefault bool `yaml:"isDefault" json:"isDefault"` // 是否默认的服务,找不到匹配域名时有限使用此配置 // 监听地址 Listen []string `yaml:"listen" json:"listen"` Root string `yaml:"root" json:"root"` // 资源根目录 Index []string `yaml:"index" json:"index"` // 默认文件 Charset string `yaml:"charset" json:"charset"` // 字符集 Locations []*LocationConfig `yaml:"locations" json:"locations"` // 地址配置 MaxBodySize string `yaml:"maxBodySize" json:"maxBodySize"` // 请求body最大尺寸 GzipLevel uint8 `yaml:"gzipLevel" json:"gzipLevel"` // Gzip压缩级别 GzipMinLength string `yaml:"gzipMinLength" json:"gzipMinLength"` // 需要压缩的最小内容尺寸 // 访问日志 AccessLog []*AccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志配置 DisableAccessLog1 bool `yaml:"disableAccessLog" json:"disableAccessLog"` // deprecated: 是否禁用访问日志 AccessLogFields1 []int `yaml:"accessLogFields" json:"accessLogFields"` // deprecated: 访问日志保留的字段,如果为nil,则表示没有设置 // 统计 DisableStat bool `yaml:"disableStat" json:"disableStat"` // 是否禁用统计 // SSL SSL *SSLConfig `yaml:"ssl" json:"ssl"` // TCP,如果有此配置的说明为TCP代理 TCP *TCPConfig `yaml:"tcp" json:"tcp"` // 参考:http://nginx.org/en/docs/http/ngx_http_access_module.html Allow []string `yaml:"allow" json:"allow"` //TODO Deny []string `yaml:"deny" json:"deny"` //TODO Filename string `yaml:"filename" json:"filename"` // 配置文件名 Proxy string `yaml:"proxy" json:"proxy"` // 代理配置 TODO CachePolicy string `yaml:"cachePolicy" json:"cachePolicy"` // 缓存策略 CacheOn bool `yaml:"cacheOn" json:"cacheOn"` // 缓存是否打开 WAFOn bool `yaml:"wafOn" json:"wafOn"` // 是否启用 WafId string `yaml:"wafId" json:"wafId"` // WAF ID // API相关 API *api.APIConfig `yaml:"api" json:"api"` // API配置 // 看板 RealtimeBoard *Board `yaml:"realtimeBoard" json:"realtimeBoard"` // 即时看板 StatBoard *Board `yaml:"statBoard" json:"statBoard"` // 统计看板 // 是否开启静态文件加速 CacheStatic bool `yaml:"cacheStatic" json:"cacheStatic"` // 请求分组 RequestGroups []*RequestGroup `yaml:"requestGroups" json:"requestGroups"` // 请求条件分组 Pages []*PageConfig `yaml:"pages" json:"pages"` // 特殊页,更高级的需求应该通过Location来设置 ShutdownPageOn bool `yaml:"shutdownPageOn" json:"shutdownPageOn"` // 是否开启临时关闭页面 ShutdownPage string `yaml:"shutdownPage" json:"shutdownPage"` // 临时关闭页面 Version int `yaml:"version" json:"version"` // 版本 // 隧道相关 Tunnel *TunnelConfig `yaml:"tunnel" json:"tunnel"` // contains filtered or unexported fields }
服务配置
func LoadServerConfigsFromDir ¶
func LoadServerConfigsFromDir(dirPath string) []*ServerConfig
从目录中加载配置
func NewServerConfigFromFile ¶
func NewServerConfigFromFile(filename string) (*ServerConfig, error)
从配置文件中读取配置信息
func (*ServerConfig) AddLocation ¶
func (this *ServerConfig) AddLocation(location *LocationConfig)
添加路径规则
func (*ServerConfig) AddPage ¶ added in v0.1.2
func (this *ServerConfig) AddPage(page *PageConfig)
添加Page
func (*ServerConfig) AddRequestGroup ¶ added in v0.1.2
func (this *ServerConfig) AddRequestGroup(group *RequestGroup)
添加请求分组
func (*ServerConfig) CachePolicyObject ¶
func (this *ServerConfig) CachePolicyObject() *shared.CachePolicy
缓存策略
func (*ServerConfig) CloneState ¶ added in v0.1.6
func (this *ServerConfig) CloneState(oldServer *ServerConfig)
克隆运行时状态
func (*ServerConfig) FindBackendList ¶
func (this *ServerConfig) FindBackendList(locationId string, websocket bool) (backendList BackendListInterface, err error)
查找后端服务器列表
func (*ServerConfig) FindFastcgiList ¶
func (this *ServerConfig) FindFastcgiList(locationId string) (fastcgiList FastcgiListInterface, err error)
查找FastcgiList
func (*ServerConfig) FindHeaderList ¶
func (this *ServerConfig) FindHeaderList(locationId string, backendId string, rewriteId string, fastcgiId string) (headerList shared.HeaderListInterface, err error)
查找HeaderList
func (*ServerConfig) FindLocation ¶
func (this *ServerConfig) FindLocation(locationId string) *LocationConfig
根据Id查找Location
func (*ServerConfig) FindRequestGroup ¶ added in v0.1.2
func (this *ServerConfig) FindRequestGroup(groupId string) *RequestGroup
查找请求分组
func (*ServerConfig) FindRewriteList ¶
func (this *ServerConfig) FindRewriteList(locationId string) (rewriteList RewriteListInterface, err error)
查找重写规则
func (*ServerConfig) LocationAtIndex ¶
func (this *ServerConfig) LocationAtIndex(index int) *LocationConfig
获取某个位置上的配置
func (*ServerConfig) MatchName ¶
func (this *ServerConfig) MatchName(name string) (matchedName string, matched bool)
判断是否和域名匹配
func (*ServerConfig) MatchRequestGroup ¶ added in v0.1.2
func (this *ServerConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup
使用请求匹配分组
func (*ServerConfig) MoveLocation ¶ added in v0.1.2
func (this *ServerConfig) MoveLocation(fromIndex int, toIndex int)
移动位置
func (*ServerConfig) NextBackend ¶ added in v0.1.2
func (this *ServerConfig) NextBackend(call *shared.RequestCall) *BackendConfig
取得下一个可用的后端服务
func (*ServerConfig) NextBackendIgnore ¶ added in v0.1.6
func (this *ServerConfig) NextBackendIgnore(call *shared.RequestCall, backendIds []string) *BackendConfig
取得下一个可用的后端服务,并排除某个后端
func (*ServerConfig) RefersProxy ¶ added in v0.1.2
func (this *ServerConfig) RefersProxy(proxyId string) (description string, referred bool)
是否在引用某个代理
func (*ServerConfig) RemoveLocation ¶
func (this *ServerConfig) RemoveLocation(locationId string)
删除Location
func (*ServerConfig) RemoveRequestGroup ¶ added in v0.1.2
func (this *ServerConfig) RemoveRequestGroup(groupId string)
删除请求分组
func (*ServerConfig) SetupScheduling ¶ added in v0.1.2
func (this *ServerConfig) SetupScheduling(isBackup bool)
设置调度算法
type ServerList ¶
type ServerList struct {
Files []string `yaml:"files" json:"files"`
}
Server列表
func (*ServerList) FindAllServers ¶
func (this *ServerList) FindAllServers() []*ServerConfig
查找所有Servers
type ServerNoticeItem ¶ added in v0.1.3
通知项
type TCPConfig ¶ added in v0.1.6
type TCPConfig struct { TCPOn bool `yaml:"tcpOn" json:"tcpOn"` // 是否开启TCP FailReconnect bool `yaml:"failReconnect" json:"failReconnect"` // 失败是否重连 FailResend bool `yaml:"failResend" json:"failResend"` // 失败是否重发 }
TCP代理配置
type TunnelConfig ¶ added in v0.1.5
type TunnelConfig struct { Id string `yaml:"id" json:"id"` // ID On bool `yaml:"on" json:"on"` // 是否启用 Endpoint string `yaml:"endpoint" json:"endpoint"` // 终端地址 Secret string `yaml:"secret" json:"secret"` // 连接用的密钥 TLS bool `yaml:"tls" json:"tls"` // 是否支持TLS TODO 暂时没有实现 Certs []*SSLCertConfig `yaml:"certs" json:"certs"` // TLS证书 TODO 暂时没有实现 // contains filtered or unexported fields }
网络隧道定义
func (*TunnelConfig) AddError ¶ added in v0.1.5
func (this *TunnelConfig) AddError(err string)
设置错误信息
func (*TunnelConfig) SetIsActive ¶ added in v0.1.5
func (this *TunnelConfig) SetIsActive(isActive bool)
设置是否已启动
type WAFList ¶ added in v0.1.3
type WAFList struct {
Files []string `yaml:"files" json:"files"`
}
WAF列表
func (*WAFList) FindAllConfigs ¶ added in v0.1.3
查找所有WAF配置
type WebsocketConfig ¶
type WebsocketConfig struct { // 后端服务器列表 BackendList `yaml:",inline"` On bool `yaml:"on" json:"on"` // 是否开启 // 握手超时时间 HandshakeTimeout string `yaml:"handshakeTimeout" json:"handshakeTimeout"` // 允许的域名,支持 www.example.com, example.com, .example.com, *.example.com AllowAllOrigins bool `yaml:"allowAllOrigins" json:"allowAllOrigins"` Origins []string `yaml:"origins" json:"origins"` // 转发方式 ForwardMode WebsocketForwardMode `yaml:"forwardMode" json:"forwardMode"` // contains filtered or unexported fields }
websocket设置
func (*WebsocketConfig) AddRequestGroup ¶ added in v0.1.2
func (this *WebsocketConfig) AddRequestGroup(group *RequestGroup)
添加请求分组
func (*WebsocketConfig) CloneState ¶ added in v0.1.6
func (this *WebsocketConfig) CloneState(oldWebsocket *WebsocketConfig)
克隆运行时状态
func (*WebsocketConfig) ForwardModeSummary ¶
func (this *WebsocketConfig) ForwardModeSummary() maps.Map
转发模式名称
func (*WebsocketConfig) HandshakeTimeoutDuration ¶
func (this *WebsocketConfig) HandshakeTimeoutDuration() time.Duration
获取握手超时时间
func (*WebsocketConfig) MatchOrigin ¶
func (this *WebsocketConfig) MatchOrigin(origin string) bool
匹配域名
func (*WebsocketConfig) MatchRequestGroup ¶ added in v0.1.2
func (this *WebsocketConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup
使用请求匹配分组
func (*WebsocketConfig) NextBackend ¶ added in v0.1.2
func (this *WebsocketConfig) NextBackend(call *shared.RequestCall) *BackendConfig
取得下一个可用的后端服务
func (*WebsocketConfig) SetupScheduling ¶ added in v0.1.2
func (this *WebsocketConfig) SetupScheduling(isBackup bool)
设置调度算法
type WildcardStatus ¶ added in v0.1.2
可能含有x字母的状态码
func NewWildcardStatus ¶ added in v0.1.2
func NewWildcardStatus(status string) *WildcardStatus
获取新对象
func (*WildcardStatus) Match ¶ added in v0.1.2
func (this *WildcardStatus) Match(status int) bool
判断匹配
Source Files ¶
- access_log.go
- access_log_storage_policy.go
- access_log_storage_policy_list.go
- backend.go
- backend_list.go
- board.go
- board_chart.go
- cache_config.go
- fastcgi.go
- fastcgi_list.go
- ip_range.go
- ip_range_list.go
- location.go
- location_pattern_types.go
- node.go
- node_role.go
- page.go
- regexp.go
- request_cond.go
- request_group.go
- rewrite_list.go
- rewrite_operators.go
- rewrite_rule.go
- scheduling.go
- server.go
- server_list.go
- server_notice_config.go
- server_notice_item.go
- ssl.go
- ssl_acme_dns_provider.go
- ssl_acme_dns_record.go
- ssl_acme_local_user.go
- ssl_acme_local_user_list.go
- ssl_acme_request.go
- ssl_acme_user.go
- ssl_cert.go
- ssl_cert_task.go
- ssl_go_1.12.go
- ssl_hsts.go
- tcp_config.go
- tunnel.go
- waf_list.go
- websocket.go
- websocket_forward.go
- wildcard_status.go