Rainbond/gateway/controller/openresty/rbd_endpoints.go

148 lines
3.5 KiB
Go
Raw Normal View History

package openresty
import (
"fmt"
2019-03-10 18:51:10 +08:00
"github.com/goodrain/rainbond/gateway/annotations/proxy"
2019-03-21 14:48:46 +08:00
"github.com/goodrain/rainbond/gateway/annotations/rewrite"
"github.com/goodrain/rainbond/gateway/controller/openresty/model"
2019-03-10 18:51:10 +08:00
"github.com/goodrain/rainbond/gateway/v1"
)
func langGoodrainMe(ip string) *model.Server {
2019-03-10 18:51:10 +08:00
proxy := proxy.NewProxyConfig()
proxy.ConnectTimeout = 60
proxy.ReadTimeout = 600
proxy.SendTimeout = 600
svr := &model.Server{
Listen: fmt.Sprintf("%s:%d", ip, 80),
ServerName: "lang.goodrain.me",
Rewrites: []model.Rewrite{
{
Regex: "^/(.*)$",
Replacement: "/artifactory/pkg_lang/$1",
Flag: "break",
},
},
Locations: []*model.Location{
{
Path: "/",
ProxyRedirect: "off",
EnableMetrics: false,
DisableAccessLog: true,
Proxy: proxy,
NameCondition: map[string]*v1.Condition{
2018-12-04 21:56:29 +08:00
"lang": {
Type: v1.DefaultType,
Value: map[string]string{"1": "1"},
},
},
},
},
}
return svr
}
func mavenGoodrainMe(ip string) *model.Server {
2019-03-10 18:51:10 +08:00
proxy := proxy.NewProxyConfig()
proxy.ConnectTimeout = 60
proxy.ReadTimeout = 600
proxy.SendTimeout = 600
svr := &model.Server{
Listen: fmt.Sprintf("%s:%d", ip, 80),
ServerName: "maven.goodrain.me",
Locations: []*model.Location{
{
EnableMetrics: false,
DisableAccessLog: true,
Path: "/",
Rewrite: rewrite.Config{
2019-03-21 14:48:46 +08:00
Rewrites: []*rewrite.Rewrite{
{
Regex: "^/(.*)$",
Replacement: "/artifactory/libs-release/$1",
Flag: "break",
},
},
},
2019-03-10 18:51:10 +08:00
ProxyRedirect: "off",
Proxy: proxy,
NameCondition: map[string]*v1.Condition{
2018-12-04 21:56:29 +08:00
"maven": {
Type: v1.DefaultType,
Value: map[string]string{"1": "1"},
},
},
},
{
2018-12-04 21:56:29 +08:00
Path: "/monitor",
2019-03-10 18:51:10 +08:00
Proxy: proxy,
2018-12-04 21:56:29 +08:00
Return: model.Return{Code: 204},
DisableProxyPass: true,
},
},
}
return svr
}
func goodrainMe(cfgPath string, ip string) *model.Server {
2019-03-10 18:51:10 +08:00
proxy := proxy.NewProxyConfig()
proxy.ReadTimeout = 900
proxy.BodySize = 0
proxy.SetHeaders["X-Forwarded-Proto"] = "https"
svr := &model.Server{
2018-12-04 21:56:29 +08:00
Listen: fmt.Sprintf("%s:%d %s", ip, 443, "ssl"),
ServerName: "goodrain.me",
SSLCertificate: fmt.Sprintf("%s/%s", cfgPath, "ssl/server.crt"),
SSLCertificateKey: fmt.Sprintf("%s/%s", cfgPath, "ssl/server.key"),
ClientMaxBodySize: model.Size{Num: 0, Unit: "k"},
ChunkedTransferEncoding: true,
Locations: []*model.Location{
{
EnableMetrics: false,
DisableAccessLog: true,
Path: "/v2/",
2019-03-21 14:48:46 +08:00
Proxy: proxy,
NameCondition: map[string]*v1.Condition{
2018-12-04 21:56:29 +08:00
"registry": {
Type: v1.DefaultType,
Value: map[string]string{"1": "1"},
},
},
},
2018-12-06 12:10:59 +08:00
{
Path: "/monitor",
2019-03-10 18:51:10 +08:00
Proxy: proxy,
2018-12-06 12:10:59 +08:00
Return: model.Return{Code: 200, Text: "ok"},
DisableProxyPass: true,
},
},
}
return svr
}
2018-12-26 13:45:01 +08:00
func repoGoodrainMe(ip string) *model.Server {
return &model.Server{
Listen: fmt.Sprintf("%s:%d", ip, 80),
Root: "/grdata/services/offline/pkgs/",
2018-12-26 13:45:01 +08:00
ServerName: "repo.goodrain.me",
}
}
2018-12-26 13:45:01 +08:00
func kubeApiserver(ip string) *model.Server {
svr := &model.Server{
Listen: fmt.Sprintf("%s:%d", ip, 6443),
ProxyPass: "kube_apiserver",
ProxyTimeout: model.Time{
Num: 10,
Unit: "m",
},
ProxyConnectTimeout: model.Time{
Num: 10,
Unit: "m",
},
}
return svr
}