@@ -131,6 +131,7 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
131
131
RealIPRecursive : ingCfg .RealIPRecursive ,
132
132
ProxyHideHeaders : ingCfg .ProxyHideHeaders ,
133
133
ProxyPassHeaders : ingCfg .ProxyPassHeaders ,
134
+ ServerSnippets : ingCfg .ServerSnippets ,
134
135
}
135
136
136
137
if pemFile , ok := pems [serverName ]; ok {
@@ -188,6 +189,7 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
188
189
RealIPRecursive : ingCfg .RealIPRecursive ,
189
190
ProxyHideHeaders : ingCfg .ProxyHideHeaders ,
190
191
ProxyPassHeaders : ingCfg .ProxyPassHeaders ,
192
+ ServerSnippets : ingCfg .ServerSnippets ,
191
193
}
192
194
193
195
if pemFile , ok := pems [emptyHost ]; ok {
@@ -223,20 +225,34 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
223
225
}
224
226
}
225
227
}
228
+ if serverSnippets , exists , err := GetMapKeyAsStringSlice (ingEx .Ingress .Annotations , "nginx.org/server-snippets" , ingEx .Ingress , "\n " ); exists {
229
+ if err != nil {
230
+ glog .Error (err )
231
+ } else {
232
+ ingCfg .ServerSnippets = serverSnippets
233
+ }
234
+ }
235
+ if locationSnippets , exists , err := GetMapKeyAsStringSlice (ingEx .Ingress .Annotations , "nginx.org/location-snippets" , ingEx .Ingress , "\n " ); exists {
236
+ if err != nil {
237
+ glog .Error (err )
238
+ } else {
239
+ ingCfg .LocationSnippets = locationSnippets
240
+ }
241
+ }
226
242
if proxyConnectTimeout , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-connect-timeout" ]; exists {
227
243
ingCfg .ProxyConnectTimeout = proxyConnectTimeout
228
244
}
229
245
if proxyReadTimeout , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-read-timeout" ]; exists {
230
246
ingCfg .ProxyReadTimeout = proxyReadTimeout
231
247
}
232
- if proxyHideHeaders , exists , err := GetMapKeyAsStringSlice (ingEx .Ingress .Annotations , "nginx.org/proxy-hide-headers" , ingEx .Ingress ); exists {
248
+ if proxyHideHeaders , exists , err := GetMapKeyAsStringSlice (ingEx .Ingress .Annotations , "nginx.org/proxy-hide-headers" , ingEx .Ingress , "," ); exists {
233
249
if err != nil {
234
250
glog .Error (err )
235
251
} else {
236
252
ingCfg .ProxyHideHeaders = proxyHideHeaders
237
253
}
238
254
}
239
- if proxyPassHeaders , exists , err := GetMapKeyAsStringSlice (ingEx .Ingress .Annotations , "nginx.org/proxy-pass-headers" , ingEx .Ingress ); exists {
255
+ if proxyPassHeaders , exists , err := GetMapKeyAsStringSlice (ingEx .Ingress .Annotations , "nginx.org/proxy-pass-headers" , ingEx .Ingress , "," ); exists {
240
256
if err != nil {
241
257
glog .Error (err )
242
258
} else {
@@ -253,7 +269,7 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
253
269
ingCfg .HTTP2 = HTTP2
254
270
}
255
271
}
256
- if redirectToHTTPS , exists ,err := GetMapKeyAsBool (ingEx .Ingress .Annotations , "nginx.org/redirect-to-https" , ingEx .Ingress ); exists {
272
+ if redirectToHTTPS , exists , err := GetMapKeyAsBool (ingEx .Ingress .Annotations , "nginx.org/redirect-to-https" , ingEx .Ingress ); exists {
257
273
if err != nil {
258
274
glog .Error (err )
259
275
} else {
@@ -416,6 +432,7 @@ func createLocation(path string, upstream Upstream, cfg *Config, websocket bool,
416
432
ProxyBuffers : cfg .ProxyBuffers ,
417
433
ProxyBufferSize : cfg .ProxyBufferSize ,
418
434
ProxyMaxTempFileSize : cfg .ProxyMaxTempFileSize ,
435
+ LocationSnippets : cfg .LocationSnippets ,
419
436
}
420
437
421
438
return loc
@@ -500,6 +517,7 @@ func (cnf *Configurator) UpdateConfig(config *Config) {
500
517
501
518
cnf .config = config
502
519
mainCfg := & NginxMainConfig {
520
+ HTTPSnippets : config .MainHTTPSnippets ,
503
521
ServerNamesHashBucketSize : config .MainServerNamesHashBucketSize ,
504
522
ServerNamesHashMaxSize : config .MainServerNamesHashMaxSize ,
505
523
LogFormat : config .MainLogFormat ,
0 commit comments