diff --git a/nginx-controller/Dockerfile b/nginx-controller/Dockerfile index 64803ad5f8..6fb220b2fd 100644 --- a/nginx-controller/Dockerfile +++ b/nginx-controller/Dockerfile @@ -22,6 +22,7 @@ EXPOSE 80 443 COPY nginx-ingress / COPY nginx/ingress.tmpl / +COPY nginx/nginx.conf /etc/nginx/nginx.conf RUN rm /etc/nginx/conf.d/* diff --git a/nginx-controller/main.go b/nginx-controller/main.go index 7abdbc1462..5c1f26dff8 100644 --- a/nginx-controller/main.go +++ b/nginx-controller/main.go @@ -45,7 +45,7 @@ func main() { resolver := getKubeDNSIP(kubeClient) ngxc, _ := nginx.NewNGINXController(resolver, "/etc/nginx/", local) - ngxc.Start() + go ngxc.Start() lbc, _ := controller.NewLoadBalancerController(kubeClient, 30*time.Second, *watchNamespace, ngxc) lbc.Run() } diff --git a/nginx-controller/nginx/nginx.conf b/nginx-controller/nginx/nginx.conf new file mode 100644 index 0000000000..3ff91487e7 --- /dev/null +++ b/nginx-controller/nginx/nginx.conf @@ -0,0 +1,33 @@ + +daemon off; +user nginx; +worker_processes 1; + +error_log stderr warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] $host "$request" ' + '$status $body_bytes_sent $request_time "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /dev/stdout main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + include /etc/nginx/conf.d/*.conf; +} diff --git a/nginx-controller/nginx/nginx.go b/nginx-controller/nginx/nginx.go index 03b160554f..6f1525d914 100644 --- a/nginx-controller/nginx/nginx.go +++ b/nginx-controller/nginx/nginx.go @@ -170,7 +170,17 @@ func (nginx *NGINXController) Reload() { // Start starts NGINX func (nginx *NGINXController) Start() { if !nginx.local { - shellOut("nginx") + command := exec.Command("nginx") + command.Stdout = os.Stdout + command.Stderr = os.Stderr + err := command.Start() + if err != nil { + glog.Fatalf("Error while starting nginx: %v", err) + } + err = command.Wait() + if err != nil { + glog.Fatalf("Error while waiting for nginx: %v", err) + } } }