@@ -111,7 +111,14 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
111
111
glog .Warningf ("Host field of ingress rule in %v/%v is empty" , ingEx .Ingress .Namespace , ingEx .Ingress .Name )
112
112
}
113
113
114
- server := Server {Name : serverName , StatusZone : statuzZone }
114
+ server := Server {
115
+ Name : serverName ,
116
+ HTTP2 : ingCfg .HTTP2 ,
117
+ HSTS : ingCfg .HSTS ,
118
+ HSTSMaxAge : ingCfg .HSTSMaxAge ,
119
+ HSTSIncludeSubdomains : ingCfg .HSTSIncludeSubdomains ,
120
+ StatusZone : statuzZone ,
121
+ }
115
122
116
123
if pemFile , ok := pems [serverName ]; ok {
117
124
server .SSL = true
@@ -153,7 +160,14 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
153
160
statuzZone := ingEx .Ingress .Namespace + "-" + ingEx .Ingress .Name
154
161
glog .Warningf ("Host field of ingress rule in %v/%v is empty" , ingEx .Ingress .Namespace , ingEx .Ingress .Name )
155
162
156
- server := Server {Name : serverName , StatusZone : statuzZone }
163
+ server := Server {
164
+ Name : serverName ,
165
+ HTTP2 : ingCfg .HTTP2 ,
166
+ HSTS : ingCfg .HSTS ,
167
+ HSTSMaxAge : ingCfg .HSTSMaxAge ,
168
+ HSTSIncludeSubdomains : ingCfg .HSTSIncludeSubdomains ,
169
+ StatusZone : statuzZone ,
170
+ }
157
171
158
172
if pemFile , ok := pems [emptyHost ]; ok {
159
173
server .SSL = true
@@ -186,7 +200,61 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
186
200
if clientMaxBodySize , exists := ingEx .Ingress .Annotations ["nginx.org/client-max-body-size" ]; exists {
187
201
ingCfg .ClientMaxBodySize = clientMaxBodySize
188
202
}
203
+ if HTTP2 , exists , err := GetMapKeyAsBool (ingEx .Ingress .Annotations , "nginx.org/http2" , ingEx .Ingress ); exists {
204
+ if err != nil {
205
+ glog .Error (err )
206
+ } else {
207
+ ingCfg .HTTP2 = HTTP2
208
+ }
209
+ }
210
+ if proxyBuffering , exists , err := GetMapKeyAsBool (ingEx .Ingress .Annotations , "nginx.org/proxy-buffering" , ingEx .Ingress ); exists {
211
+ if err != nil {
212
+ glog .Error (err )
213
+ } else {
214
+ ingCfg .ProxyBuffering = proxyBuffering
215
+ }
216
+ }
217
+
218
+ if hsts , exists , err := GetMapKeyAsBool (ingEx .Ingress .Annotations , "nginx.org/hsts" , ingEx .Ingress ); exists {
219
+ if err != nil {
220
+ glog .Error (err )
221
+ } else {
222
+ parsingErrors := false
223
+
224
+ hstsMaxAge , existsMA , err := GetMapKeyAsInt (ingEx .Ingress .Annotations , "nginx.org/hsts-max-age" , ingEx .Ingress )
225
+ if existsMA && err != nil {
226
+ glog .Error (err )
227
+ parsingErrors = true
228
+ }
229
+ hstsIncludeSubdomains , existsIS , err := GetMapKeyAsBool (ingEx .Ingress .Annotations , "nginx.org/hsts-include-subdomains" , ingEx .Ingress )
230
+ if existsIS && err != nil {
231
+ glog .Error (err )
232
+ parsingErrors = true
233
+ }
234
+
235
+ if parsingErrors {
236
+ glog .Errorf ("Ingress %s/%s: There are configuration issues with hsts annotations, skipping annotions for all hsts settings" , ingEx .Ingress .GetNamespace (), ingEx .Ingress .GetName ())
237
+ } else {
238
+ ingCfg .HSTS = hsts
239
+ if existsMA {
240
+ ingCfg .HSTSMaxAge = hstsMaxAge
241
+ }
242
+ if existsIS {
243
+ ingCfg .HSTSIncludeSubdomains = hstsIncludeSubdomains
244
+ }
245
+ }
246
+ }
247
+ }
189
248
249
+ if proxyBuffers , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-buffers" ]; exists {
250
+ ingCfg .ProxyBuffers = proxyBuffers
251
+ }
252
+ if proxyBufferSize , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-buffer-size" ]; exists {
253
+ ingCfg .ProxyBufferSize = proxyBufferSize
254
+ }
255
+ if proxyMaxTempFileSize , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-max-temp-file-size" ]; exists {
256
+ ingCfg .ProxyMaxTempFileSize = proxyMaxTempFileSize
257
+ }
190
258
return ingCfg
191
259
}
192
260
@@ -283,14 +351,18 @@ func parseStickyService(service string) (serviceName string, stickyCookie string
283
351
284
352
func createLocation (path string , upstream Upstream , cfg * Config , websocket bool , rewrite string , ssl bool ) Location {
285
353
loc := Location {
286
- Path : path ,
287
- Upstream : upstream ,
288
- ProxyConnectTimeout : cfg .ProxyConnectTimeout ,
289
- ProxyReadTimeout : cfg .ProxyReadTimeout ,
290
- ClientMaxBodySize : cfg .ClientMaxBodySize ,
291
- Websocket : websocket ,
292
- Rewrite : rewrite ,
293
- SSL : ssl ,
354
+ Path : path ,
355
+ Upstream : upstream ,
356
+ ProxyConnectTimeout : cfg .ProxyConnectTimeout ,
357
+ ProxyReadTimeout : cfg .ProxyReadTimeout ,
358
+ ClientMaxBodySize : cfg .ClientMaxBodySize ,
359
+ Websocket : websocket ,
360
+ Rewrite : rewrite ,
361
+ SSL : ssl ,
362
+ ProxyBuffering : cfg .ProxyBuffering ,
363
+ ProxyBuffers : cfg .ProxyBuffers ,
364
+ ProxyBufferSize : cfg .ProxyBufferSize ,
365
+ ProxyMaxTempFileSize : cfg .ProxyMaxTempFileSize ,
294
366
}
295
367
296
368
return loc
@@ -377,6 +449,7 @@ func (cnf *Configurator) UpdateConfig(config *Config) {
377
449
mainCfg := & NginxMainConfig {
378
450
ServerNamesHashBucketSize : config .MainServerNamesHashBucketSize ,
379
451
ServerNamesHashMaxSize : config .MainServerNamesHashMaxSize ,
452
+ LogFormat : config .MainLogFormat ,
380
453
}
381
454
382
455
cnf .nginx .UpdateMainConfigFile (mainCfg )
0 commit comments