@@ -131,6 +131,7 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
131131 RealIPRecursive : ingCfg .RealIPRecursive ,
132132 ProxyHideHeaders : ingCfg .ProxyHideHeaders ,
133133 ProxyPassHeaders : ingCfg .ProxyPassHeaders ,
134+ ServerSnippets : ingCfg .ServerSnippets ,
134135 }
135136
136137 if pemFile , ok := pems [serverName ]; ok {
@@ -188,6 +189,7 @@ func (cnf *Configurator) generateNginxCfg(ingEx *IngressEx, pems map[string]stri
188189 RealIPRecursive : ingCfg .RealIPRecursive ,
189190 ProxyHideHeaders : ingCfg .ProxyHideHeaders ,
190191 ProxyPassHeaders : ingCfg .ProxyPassHeaders ,
192+ ServerSnippets : ingCfg .ServerSnippets ,
191193 }
192194
193195 if pemFile , ok := pems [emptyHost ]; ok {
@@ -223,20 +225,34 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
223225 }
224226 }
225227 }
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+ }
226242 if proxyConnectTimeout , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-connect-timeout" ]; exists {
227243 ingCfg .ProxyConnectTimeout = proxyConnectTimeout
228244 }
229245 if proxyReadTimeout , exists := ingEx .Ingress .Annotations ["nginx.org/proxy-read-timeout" ]; exists {
230246 ingCfg .ProxyReadTimeout = proxyReadTimeout
231247 }
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 {
233249 if err != nil {
234250 glog .Error (err )
235251 } else {
236252 ingCfg .ProxyHideHeaders = proxyHideHeaders
237253 }
238254 }
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 {
240256 if err != nil {
241257 glog .Error (err )
242258 } else {
@@ -253,7 +269,7 @@ func (cnf *Configurator) createConfig(ingEx *IngressEx) Config {
253269 ingCfg .HTTP2 = HTTP2
254270 }
255271 }
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 {
257273 if err != nil {
258274 glog .Error (err )
259275 } else {
@@ -416,6 +432,7 @@ func createLocation(path string, upstream Upstream, cfg *Config, websocket bool,
416432 ProxyBuffers : cfg .ProxyBuffers ,
417433 ProxyBufferSize : cfg .ProxyBufferSize ,
418434 ProxyMaxTempFileSize : cfg .ProxyMaxTempFileSize ,
435+ LocationSnippets : cfg .LocationSnippets ,
419436 }
420437
421438 return loc
@@ -500,6 +517,7 @@ func (cnf *Configurator) UpdateConfig(config *Config) {
500517
501518 cnf .config = config
502519 mainCfg := & NginxMainConfig {
520+ HTTPSnippets : config .MainHTTPSnippets ,
503521 ServerNamesHashBucketSize : config .MainServerNamesHashBucketSize ,
504522 ServerNamesHashMaxSize : config .MainServerNamesHashMaxSize ,
505523 LogFormat : config .MainLogFormat ,
0 commit comments