2018-11-08 17:22:26 +08:00
|
|
|
package model
|
|
|
|
|
2018-11-21 17:35:07 +08:00
|
|
|
import "github.com/goodrain/rainbond/cmd/gateway/option"
|
|
|
|
|
2018-11-23 14:34:44 +08:00
|
|
|
// HTTP contains data for nginx http configuration
|
|
|
|
type HTTP struct {
|
2018-11-08 17:22:26 +08:00
|
|
|
DefaultType string
|
|
|
|
SendFile bool
|
|
|
|
KeepaliveTimeout Time
|
2018-11-21 17:35:07 +08:00
|
|
|
keepaliveRequests int
|
2018-11-08 17:22:26 +08:00
|
|
|
ClientMaxBodySize Size
|
|
|
|
ClientBodyBufferSize Size
|
|
|
|
ProxyConnectTimeout Time
|
|
|
|
ProxySendTimeout Time
|
|
|
|
ProxyReadTimeout Time
|
|
|
|
ProxyBufferSize Size
|
|
|
|
ProxyBuffers Size
|
|
|
|
ProxyBusyBuffersSize Size
|
2018-12-05 22:06:21 +08:00
|
|
|
StatusPort int
|
2018-11-23 14:34:44 +08:00
|
|
|
UpstreamsDict Size
|
2019-08-28 21:41:44 +08:00
|
|
|
HTTPListen int
|
|
|
|
HTTPSListen int
|
2020-06-14 18:21:09 +08:00
|
|
|
AccessLogPath string
|
|
|
|
DisableAccessLog bool
|
2018-11-08 17:22:26 +08:00
|
|
|
}
|
|
|
|
|
2019-03-10 18:51:10 +08:00
|
|
|
// LogFormat -
|
2018-11-08 17:22:26 +08:00
|
|
|
type LogFormat struct {
|
|
|
|
Name string
|
|
|
|
Format string
|
|
|
|
}
|
|
|
|
|
2019-03-10 18:51:10 +08:00
|
|
|
// AccessLog -
|
2018-11-08 17:22:26 +08:00
|
|
|
type AccessLog struct {
|
|
|
|
Name string
|
|
|
|
Path string
|
|
|
|
}
|
|
|
|
|
2018-11-23 14:34:44 +08:00
|
|
|
// NewHTTP creates a new model.HTTP
|
|
|
|
func NewHTTP(conf *option.Config) *HTTP {
|
|
|
|
return &HTTP{
|
2020-06-14 18:21:09 +08:00
|
|
|
HTTPListen: conf.ListenPorts.HTTP,
|
|
|
|
HTTPSListen: conf.ListenPorts.HTTPS,
|
|
|
|
DefaultType: "text/html",
|
|
|
|
SendFile: true,
|
|
|
|
StatusPort: conf.ListenPorts.Status,
|
|
|
|
AccessLogPath: conf.AccessLogPath,
|
|
|
|
DisableAccessLog: conf.AccessLogPath == "",
|
2018-11-08 17:22:26 +08:00
|
|
|
KeepaliveTimeout: Time{
|
2018-11-22 21:16:00 +08:00
|
|
|
Num: 30,
|
2018-11-08 17:22:26 +08:00
|
|
|
Unit: "s",
|
|
|
|
},
|
|
|
|
ClientMaxBodySize: Size{
|
|
|
|
Num: 10,
|
|
|
|
Unit: "m",
|
|
|
|
},
|
|
|
|
ClientBodyBufferSize: Size{
|
|
|
|
Num: 128,
|
|
|
|
Unit: "k",
|
|
|
|
},
|
|
|
|
ProxyConnectTimeout: Time{
|
|
|
|
Num: 75,
|
|
|
|
Unit: "s",
|
|
|
|
},
|
|
|
|
ProxySendTimeout: Time{
|
|
|
|
Num: 75,
|
|
|
|
Unit: "s",
|
|
|
|
},
|
|
|
|
ProxyReadTimeout: Time{
|
|
|
|
Num: 75,
|
|
|
|
Unit: "s",
|
|
|
|
},
|
|
|
|
ProxyBufferSize: Size{
|
|
|
|
Num: 8,
|
|
|
|
Unit: "k",
|
|
|
|
},
|
|
|
|
ProxyBuffers: Size{
|
|
|
|
Num: 32,
|
|
|
|
Unit: "k",
|
|
|
|
},
|
2018-11-23 14:34:44 +08:00
|
|
|
UpstreamsDict: Size{
|
2020-01-14 18:55:58 +08:00
|
|
|
Num: int(conf.ShareMemory),
|
|
|
|
Unit: "m",
|
2018-11-23 14:34:44 +08:00
|
|
|
},
|
2018-11-08 17:22:26 +08:00
|
|
|
}
|
|
|
|
}
|