forked from nginx/kubernetes-ingress
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.go
175 lines (159 loc) · 4.57 KB
/
config.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package version1
// IngressNginxConfig describes an NGINX configuration.
type IngressNginxConfig struct {
Upstreams []Upstream
Servers []Server
Keepalive string
Ingress Ingress
}
// Ingress holds information about an Ingress resource.
type Ingress struct {
Name string
Namespace string
Annotations map[string]string
}
// Upstream describes an NGINX upstream.
type Upstream struct {
Name string
UpstreamServers []UpstreamServer
StickyCookie string
LBMethod string
Queue int64
QueueTimeout int64
}
// UpstreamServer describes a server in an NGINX upstream.
type UpstreamServer struct {
Address string
Port string
MaxFails int
FailTimeout string
SlowStart string
Resolve bool
}
// HealthCheck describes an active HTTP health check.
type HealthCheck struct {
UpstreamName string
URI string
Interval int32
Fails int32
Passes int32
Scheme string
Mandatory bool
Headers map[string]string
TimeoutSeconds int64
}
// Server describes an NGINX server.
type Server struct {
ServerSnippets []string
Name string
ServerTokens string
Locations []Location
SSL bool
SSLCertificate string
SSLCertificateKey string
SSLCiphers string
GRPCOnly bool
StatusZone string
HTTP2 bool
RedirectToHTTPS bool
SSLRedirect bool
ProxyProtocol bool
HSTS bool
HSTSMaxAge int64
HSTSIncludeSubdomains bool
HSTSBehindProxy bool
ProxyHideHeaders []string
ProxyPassHeaders []string
HealthChecks map[string]HealthCheck
RealIPHeader string
SetRealIPFrom []string
RealIPRecursive bool
JWTAuth *JWTAuth
JWTRedirectLocations []JWTRedirectLocation
Ports []int
SSLPorts []int
}
// JWTRedirectLocation describes a location for redirecting client requests to a login URL for JWT Authentication.
type JWTRedirectLocation struct {
Name string
LoginURL string
}
// JWTAuth holds JWT authentication configuration.
type JWTAuth struct {
Key string
Realm string
Token string
RedirectLocationName string
}
// Location describes an NGINX location.
type Location struct {
LocationSnippets []string
Path string
Upstream Upstream
ProxyConnectTimeout string
ProxyReadTimeout string
ClientMaxBodySize string
Websocket bool
Rewrite string
SSL bool
GRPC bool
ProxyBuffering bool
ProxyBuffers string
ProxyBufferSize string
ProxyMaxTempFileSize string
JWTAuth *JWTAuth
MinionIngress *Ingress
}
// MainConfig describe the main NGINX configuration file.
type MainConfig struct {
ServerNamesHashBucketSize string
ServerNamesHashMaxSize string
AccessLogOff bool
LogFormat string
ErrorLogLevel string
StreamLogFormat string
HealthStatus bool
NginxStatus bool
NginxStatusAllowCIDRs []string
NginxStatusPort int
StubStatusOverUnixSocketForOSS bool
MainSnippets []string
HTTPSnippets []string
StreamSnippets []string
SSLProtocols string
SSLPreferServerCiphers bool
SSLCiphers string
SSLDHParam string
HTTP2 bool
ServerTokens string
ProxyProtocol bool
WorkerProcesses string
WorkerCPUAffinity string
WorkerShutdownTimeout string
WorkerConnections string
WorkerRlimitNofile string
ResolverAddresses []string
ResolverIPV6 bool
ResolverValid string
ResolverTimeout string
KeepaliveTimeout string
KeepaliveRequests int64
VariablesHashBucketSize uint64
VariablesHashMaxSize uint64
}
// NewUpstreamWithDefaultServer creates an upstream with the default server.
// proxy_pass to an upstream with the default server returns 502.
// We use it for services that have no endpoints.
func NewUpstreamWithDefaultServer(name string) Upstream {
return Upstream{
Name: name,
UpstreamServers: []UpstreamServer{
{
Address: "127.0.0.1",
Port: "8181",
MaxFails: 1,
FailTimeout: "10s",
},
},
}
}