diff --git a/nginx-controller/nginx/nginx.go b/nginx-controller/nginx/nginx.go index 57f5e28d74..49eef15492 100644 --- a/nginx-controller/nginx/nginx.go +++ b/nginx-controller/nginx/nginx.go @@ -18,6 +18,7 @@ type NginxController struct { nginxConfdPath string nginxCertsPath string local bool + healthStatus bool } // IngressNginxConfig describes an NGINX configuration @@ -109,13 +110,14 @@ func NewNginxController(nginxConfPath string, local bool, healthStatus bool) (*N nginxConfdPath: path.Join(nginxConfPath, "conf.d"), nginxCertsPath: path.Join(nginxConfPath, "ssl"), local: local, + healthStatus: healthStatus, } if !local { createDir(ngxc.nginxCertsPath) } - cfg := &NginxMainConfig{ServerNamesHashMaxSize: NewDefaultConfig().MainServerNamesHashMaxSize, HealthStatus: healthStatus} + cfg := &NginxMainConfig{ServerNamesHashMaxSize: NewDefaultConfig().MainServerNamesHashMaxSize} ngxc.UpdateMainConfigFile(cfg) return &ngxc, nil @@ -281,6 +283,8 @@ func shellOut(cmd string) (err error) { // UpdateMainConfigFile update the main NGINX configuration file func (nginx *NginxController) UpdateMainConfigFile(cfg *NginxMainConfig) { + cfg.HealthStatus = nginx.healthStatus + tmpl, err := template.New("nginx.conf.tmpl").ParseFiles("nginx.conf.tmpl") if err != nil { glog.Fatalf("Failed to parse the main config template file: %v", err) diff --git a/nginx-plus-controller/nginx/nginx.go b/nginx-plus-controller/nginx/nginx.go index e828dacdc7..227e89b783 100644 --- a/nginx-plus-controller/nginx/nginx.go +++ b/nginx-plus-controller/nginx/nginx.go @@ -18,6 +18,7 @@ type NginxController struct { nginxConfdPath string nginxCertsPath string local bool + healthStatus bool } // IngressNginxConfig describes an NGINX configuration @@ -101,13 +102,14 @@ func NewNginxController(nginxConfPath string, local bool, healthStatus bool) (*N nginxConfdPath: path.Join(nginxConfPath, "conf.d"), nginxCertsPath: path.Join(nginxConfPath, "ssl"), local: local, + healthStatus: healthStatus, } if !local { createDir(ngxc.nginxCertsPath) } - cfg := &NginxMainConfig{ServerNamesHashMaxSize: NewDefaultConfig().MainServerNamesHashMaxSize, HealthStatus: healthStatus} + cfg := &NginxMainConfig{ServerNamesHashMaxSize: NewDefaultConfig().MainServerNamesHashMaxSize} ngxc.UpdateMainConfigFile(cfg) return &ngxc, nil @@ -272,6 +274,8 @@ func shellOut(cmd string) (err error) { // UpdateMainConfigFile update the main NGINX configuration file func (nginx *NginxController) UpdateMainConfigFile(cfg *NginxMainConfig) { + cfg.HealthStatus = nginx.healthStatus + tmpl, err := template.New("nginx.conf.tmpl").ParseFiles("nginx.conf.tmpl") if err != nil { glog.Fatalf("Failed to parse the main config template file: %v", err)