X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0203f7c34ebeedf9611b11de5d9309d5a125d3a5..907d851d91a5ba8071e13f9ea4bf3608d7fe5723:/lib/boot/nginx.go diff --git a/lib/boot/nginx.go b/lib/boot/nginx.go index b90c9b537a..e67bc1d900 100644 --- a/lib/boot/nginx.go +++ b/lib/boot/nginx.go @@ -12,7 +12,6 @@ import ( "net/url" "os" "os/exec" - "os/user" "path/filepath" "regexp" @@ -33,12 +32,13 @@ func (runNginx) Run(ctx context.Context, fail func(error), super *Supervisor) er return err } vars := map[string]string{ - "LISTENHOST": super.ListenHost, - "SSLCERT": filepath.Join(super.tempdir, "server.crt"), - "SSLKEY": filepath.Join(super.tempdir, "server.key"), - "ACCESSLOG": filepath.Join(super.tempdir, "nginx_access.log"), - "ERRORLOG": filepath.Join(super.tempdir, "nginx_error.log"), - "TMPDIR": super.wwwtempdir, + "LISTENHOST": super.ListenHost, + "SSLCERT": filepath.Join(super.tempdir, "server.crt"), + "SSLKEY": filepath.Join(super.tempdir, "server.key"), + "ACCESSLOG": filepath.Join(super.tempdir, "nginx_access.log"), + "ERRORLOG": filepath.Join(super.tempdir, "nginx_error.log"), + "TMPDIR": super.wwwtempdir, + "ARVADOS_API_HOST": super.cluster.Services.Controller.ExternalURL.Host, } u := url.URL(super.cluster.Services.Controller.ExternalURL) ctrlHost := u.Hostname() @@ -116,28 +116,18 @@ func (runNginx) Run(ctx context.Context, fail func(error), super *Supervisor) er } } - args := []string{ - "-g", "error_log stderr info;", - "-g", "pid " + filepath.Join(super.wwwtempdir, "nginx.pid") + ";", - "-c", conffile, - } - // Nginx ignores "user www-data;" when running as a non-root - // user... except that it causes it to ignore our other -g - // options. So we still have to decide for ourselves whether - // it's needed. - if u, err := user.Current(); err != nil { - return fmt.Errorf("user.Current(): %w", err) - } else if u.Uid == "0" { - args = append([]string{"-g", "user www-data;"}, args...) - } + configs := "error_log stderr info; " + configs += "pid " + filepath.Join(super.wwwtempdir, "nginx.pid") + "; " + configs += "user www-data; " super.waitShutdown.Add(1) go func() { defer super.waitShutdown.Done() - fail(super.RunProgram(ctx, ".", runOptions{}, nginx, args...)) + fail(super.RunProgram(ctx, ".", runOptions{}, nginx, "-g", configs, "-c", conffile)) }() // Choose one of the ports where Nginx should listen, and wait - // here until we can connect. If ExternalURL is https://foo (with no port) then we connect to "foo:https" + // here until we can connect. If ExternalURL is https://foo + // (with no port) then we connect to "foo:https" testurl := url.URL(super.cluster.Services.Controller.ExternalURL) if testurl.Port() == "" { testurl.Host = net.JoinHostPort(testurl.Host, testurl.Scheme)