forked from goodrain/rainbond
/
rbd_endpoints.go
147 lines (139 loc) · 3.45 KB
/
rbd_endpoints.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package openresty
import (
"fmt"
"github.com/goodrain/rainbond/gateway/annotations/proxy"
"github.com/goodrain/rainbond/gateway/annotations/rewrite"
"github.com/goodrain/rainbond/gateway/controller/openresty/model"
"github.com/goodrain/rainbond/gateway/v1"
)
func langGoodrainMe(ip string) *model.Server {
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{
"lang": {
Type: v1.DefaultType,
Value: map[string]string{"1": "1"},
},
},
},
},
}
return svr
}
func mavenGoodrainMe(ip string) *model.Server {
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{
Rewrites: []*rewrite.Rewrite{
{
Regex: "^/(.*)$",
Replacement: "/artifactory/libs-release/$1",
Flag: "break",
},
},
},
ProxyRedirect: "off",
Proxy: proxy,
NameCondition: map[string]*v1.Condition{
"maven": {
Type: v1.DefaultType,
Value: map[string]string{"1": "1"},
},
},
},
{
Path: "/monitor",
Proxy: proxy,
Return: model.Return{Code: 204},
DisableProxyPass: true,
},
},
}
return svr
}
func goodrainMe(cfgPath string, ip string) *model.Server {
proxy := proxy.NewProxyConfig()
proxy.ReadTimeout = 900
proxy.BodySize = 0
proxy.SetHeaders["X-Forwarded-Proto"] = "https"
svr := &model.Server{
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/",
Proxy: proxy,
NameCondition: map[string]*v1.Condition{
"registry": {
Type: v1.DefaultType,
Value: map[string]string{"1": "1"},
},
},
},
{
Path: "/monitor",
Proxy: proxy,
Return: model.Return{Code: 200, Text: "ok"},
DisableProxyPass: true,
},
},
}
return svr
}
func repoGoodrainMe(ip string) *model.Server {
return &model.Server{
Listen: fmt.Sprintf("%s:%d", ip, 80),
Root: "/grdata/services/offline/pkgs/",
ServerName: "repo.goodrain.me",
}
}
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
}