Documentation ¶
Index ¶
- Constants
- Variables
- func AllLocationPatternTypes() []maps.Map
- func AllRewriteOperators() []maps.Map
- func AllWebsocketForwardModes() []maps.Map
- func FindLocationPatternType(patternType int) maps.Map
- func FindLocationPatternTypeName(patternType int) string
- func FindRewriteOperator(op string) maps.Map
- type AccessLogConfig
- type AccessLogFileConfig
- type AccessLogPipeConfig
- type AccessLogStdoutConfig
- type BackendConfig
- func (this *BackendConfig) CandidateCodes() []string
- func (this *BackendConfig) CandidateWeight() uint
- func (this *BackendConfig) DecreaseConn()
- func (this *BackendConfig) FailTimeoutDuration() time.Duration
- func (this *BackendConfig) IncreaseConn()
- func (this *BackendConfig) IncreaseFails() uint
- func (this *BackendConfig) ReadTimeoutDuration() time.Duration
- func (this *BackendConfig) Validate() error
- type BackendList
- func (this *BackendList) AddBackend(backend *BackendConfig)
- func (this *BackendList) AllBackends() []*BackendConfig
- func (this *BackendList) DeleteBackend(backendId string)
- func (this *BackendList) FindBackend(backendId string) *BackendConfig
- func (this *BackendList) NextBackend(options maps.Map) *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) 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 ListenerConfig
- type LocationConfig
- func (this *LocationConfig) CachePolicyObject() *shared.CachePolicy
- func (this *LocationConfig) GzipMinBytes() int64
- func (this *LocationConfig) IsCaseInsensitive() bool
- func (this *LocationConfig) IsReverse() bool
- func (this *LocationConfig) Match(path string) (map[string]string, bool)
- func (this *LocationConfig) MaxBodyBytes() int64
- func (this *LocationConfig) PatternString() string
- func (this *LocationConfig) PatternType() int
- func (this *LocationConfig) SetPattern(pattern string, patternType int, caseInsensitive bool, reverse bool)
- func (this *LocationConfig) Validate() error
- type LocationPatternType
- type RewriteCond
- 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 RewriteOperator
- type RewriteRule
- func (this *RewriteRule) AddCond(cond *RewriteCond)
- 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) ResetFlags()
- func (this *RewriteRule) TargetProxy() string
- func (this *RewriteRule) TargetType() int
- func (this *RewriteRule) TargetURL() string
- func (this *RewriteRule) Validate() error
- type SSLConfig
- 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) CachePolicyObject() *shared.CachePolicy
- 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) FindRewriteList(locationId string) (rewriteList RewriteListInterface, err error)
- func (this *ServerConfig) FirstName() string
- func (this *ServerConfig) GzipMinBytes() int64
- func (this *ServerConfig) LocationAtIndex(index int) *LocationConfig
- func (this *ServerConfig) MatchName(name string) (matchedName string, matched bool)
- func (this *ServerConfig) MaxBodyBytes() int64
- func (this *ServerConfig) RemoveLocation(locationId string)
- func (this *ServerConfig) Save() error
- func (this *ServerConfig) Validate() error
- func (this *ServerConfig) WriteToFile(path string) error
- func (this *ServerConfig) WriteToFilename(filename string) error
- type ServerList
- type WebsocketConfig
- type WebsocketForwardMode
Constants ¶
const ( LocationPatternTypePrefix = 1 LocationPatternTypeExact = 2 LocationPatternTypeRegexp = 3 )
内置的匹配类型定义
const ( RewriteOperatorRegexp = "regexp" RewriteOperatorGt = "gt" RewriteOperatorGte = "gte" RewriteOperatorLt = "lt" RewriteOperatorLte = "lte" RewriteOperatorEq = "eq" RewriteOperatorNot = "not" RewriteOperatorPrefix = "prefix" RewriteOperatorSuffix = "suffix" RewriteOperatorContains = "contains" )
const ( RewriteTargetProxy = 1 RewriteTargetURL = 2 )
const ( RewriteFlagRedirect = "r" // 跳转,TODO: 实现 302, 305 RewriteFlagProxy = "p" // 代理 )
const ( WebsocketForwardModeWebsocket = "websocket" WebsocketForwardModeHttp = "http" )
Variables ¶
var RegexpDigitNumber = regexp.MustCompile("^\\d+$")
var RegexpDigitVariable = regexp.MustCompile("\\${\\d+}")
var RegexpExternalURL = regexp.MustCompile("(?i)^(http|https|ftp)://")
var RegexpNamedVariable = regexp.MustCompile("\\${[\\w.-]+}")
Functions ¶
func FindLocationPatternTypeName ¶
查找单个匹配类型名称
Types ¶
type AccessLogConfig ¶
type AccessLogConfig struct { On bool `yaml:"on" json:"on"` Target string `yaml:"target" json:"target"` Config map[string]interface{} `yaml:"config" json:"config"` }
日志配置 参考 http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log
func (*AccessLogConfig) Validate ¶
func (config *AccessLogConfig) Validate()
type AccessLogFileConfig ¶
type AccessLogFileConfig struct { Path string `yaml:"path"` Format string `yaml:"format"` Buffer string `yaml:"buffer"` // @TODO Flush string `yaml:"flush"` // @TODO }
日志文件配置
type AccessLogPipeConfig ¶
type AccessLogPipeConfig struct { Path string `yaml:"path"` Format string `yaml:"format"` // @TODO Buffer string `yaml:"buffer"` // @TODO Flush string `yaml:"flush"` // @TODO }
日志pipe配置
type AccessLogStdoutConfig ¶
type AccessLogStdoutConfig struct { Format string `yaml:"format"` Buffer string `yaml:"buffer"` // @TODO Flush string `yaml:"flush"` // @TODO }
日志stdout配置
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"` // 代号 Name []string `yaml:"name" json:"name"` // 域名 TODO Address string `yaml:"address" json:"address"` // 地址 Scheme string `yaml:"scheme" json:"scheme"` // 协议,http或者https 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 uint `yaml:"maxFails" json:"maxFails"` // 最多失败次数 CurrentFails uint `yaml:"currentFails" json:"currentFails"` // 当前已失败次数 MaxConns uint `yaml:"maxConns" json:"maxConns"` // 最大并发连接数 CurrentConns uint `yaml:"currentConns" json:"currentConns"` // 当前连接数 IsDown bool `yaml:"down" json:"isDown"` // 是否下线 DownTime time.Time `yaml:"downTime,omitempty" json:"downTime,omitempty"` // 下线时间 // contains filtered or unexported fields }
服务后端配置
func (*BackendConfig) FailTimeoutDuration ¶
func (this *BackendConfig) FailTimeoutDuration() time.Duration
连接超时时间
func (*BackendConfig) ReadTimeoutDuration ¶
func (this *BackendConfig) ReadTimeoutDuration() time.Duration
读取超时时间
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) DeleteBackend ¶
func (this *BackendList) DeleteBackend(backendId string)
删除后端服务器
func (*BackendList) FindBackend ¶
func (this *BackendList) FindBackend(backendId string) *BackendConfig
根据ID查找后端服务器
func (*BackendList) NextBackend ¶
func (this *BackendList) NextBackend(options maps.Map) *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"` // 连接池尺寸 // contains filtered or unexported fields }
Fastcgi配置 参考:http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html
func (*FastcgiConfig) FilterParams ¶
func (this *FastcgiConfig) FilterParams(req *http.Request) maps.Map
过滤参数
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 ListenerConfig ¶
type ListenerConfig struct { Key string // 区分用的Key Address string Http bool SSL *SSLConfig Servers []*ServerConfig }
本地监听服务配置
func (*ListenerConfig) AddServer ¶
func (this *ListenerConfig) AddServer(serverConfig *ServerConfig)
添加服务
func (*ListenerConfig) FindNamedServer ¶
func (this *ListenerConfig) FindNamedServer(name string) (serverConfig *ServerConfig, serverName string)
根据域名来查找匹配的域名 @TODO 把查找的结果加入缓存
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 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"` // 访问控制 // 日志 DisableAccessLog bool `yaml:"disableAccessLog" json:"disableAccessLog"` // 是否禁用访问日志 AccessLog []*AccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志设置 TODO // 参考: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"` // 缓存是否打开 TODO // websocket设置 Websocket *WebsocketConfig `yaml:"websocket" json:"websocket"` // contains filtered or unexported fields }
路径配置
func (*LocationConfig) CachePolicyObject ¶
func (this *LocationConfig) CachePolicyObject() *shared.CachePolicy
缓存策略
func (*LocationConfig) IsCaseInsensitive ¶
func (this *LocationConfig) IsCaseInsensitive() bool
是否大小写非敏感
func (*LocationConfig) Match ¶
func (this *LocationConfig) Match(path string) (map[string]string, bool)
判断是否匹配路径
func (*LocationConfig) PatternString ¶
func (this *LocationConfig) PatternString() string
模式字符串 去掉了模式字符
func (*LocationConfig) SetPattern ¶
func (this *LocationConfig) SetPattern(pattern string, patternType int, caseInsensitive bool, reverse bool)
组合参数为一个字符串
type RewriteCond ¶
type RewriteCond struct { Id string `yaml:"id" json:"id"` // ID // 要测试的字符串 // 其中可以使用跟请求相关的参数,比如: // ${arg.name}, ${requestPath} Param string `yaml:"param" json:"param"` // 运算符 Operator RewriteOperator `yaml:"operator" json:"operator"` // 对比 Value string `yaml:"value" json:"value"` // contains filtered or unexported fields }
重写条件定义
func (*RewriteCond) Match ¶
func (this *RewriteCond) 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 []*RewriteCond `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)
对某个请求执行规则
type SSLConfig ¶
type SSLConfig struct { On bool `yaml:"on" json:"on"` // 是否开启 Certificate string `yaml:"certificate" json:"certificate"` // 证书文件 CertificateKey string `yaml:"certificateKey" json:"certificateKey"` // 密钥 Listen []string `yaml:"listen" json:"listen"` // 网络地址 }
SSL配置
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"` // 是否开启 @TODO Id string `yaml:"id" json:"id"` // ID Description string `yaml:"description" json:"description"` // 描述 Name []string `yaml:"name" json:"name"` // 域名 Http bool `yaml:"http" json:"http"` // 是否支持HTTP // 监听地址 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"` // 需要压缩的最小内容尺寸 Async bool `yaml:"async" json:"async"` // 请求是否异步处理 @TODO Notify []string `yaml:"notify" json:"notify"` // 请求转发地址 @TODO LogOnly bool `yaml:"logOnly" json:"logOnly"` // 是否只记录日志 @TODO // 访问日志 DisableAccessLog bool `yaml:"disableAccessLog" json:"disableAccessLog"` // 是否禁用访问日志 AccessLog []*AccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志,TODO // SSL SSL *SSLConfig `yaml:"ssl" json:"ssl"` // 参考: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"` // 缓存是否打开 // API相关 API *api.APIConfig `yaml:"api" json:"api"` // API配置 // 看板 RealtimeBoard *Board `yaml:"realtimeBoard" json:"realtimeBoard"` // 即时看板 StatBoard *Board `yaml:"statBoard" json:"statBoard"` // 统计看板 // 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) CachePolicyObject ¶
func (this *ServerConfig) CachePolicyObject() *shared.CachePolicy
缓存策略
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) 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) RemoveLocation ¶
func (this *ServerConfig) RemoveLocation(locationId string)
删除Location
func (*ServerConfig) WriteToFilename ¶
func (this *ServerConfig) WriteToFilename(filename string) error
将配置写入文件
type ServerList ¶
type ServerList struct {
Files []string `yaml:"files" json:"files"`
}
Server列表
func (*ServerList) FindAllServers ¶
func (this *ServerList) FindAllServers() []*ServerConfig
查找所有Servers
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) 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
匹配域名
Source Files ¶
- access_log.go
- access_log_file.go
- access_log_pipe.go
- access_log_stdout.go
- backend.go
- backend_list.go
- board.go
- board_chart.go
- cache_config.go
- fastcgi.go
- fastcgi_list.go
- listener.go
- location.go
- location_pattern_types.go
- regexp.go
- rewrite_cond.go
- rewrite_list.go
- rewrite_operators.go
- rewrite_rule.go
- scheduling.go
- server.go
- server_list.go
- ssl.go
- websocket.go
- websocket_forward.go