1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
17 "git.arvados.org/arvados.git/sdk/go/arvados"
20 func runNginx(ctx context.Context, boot *bootCommand, stdout, stderr io.Writer) error {
21 vars := map[string]string{
22 "SSLCERT": filepath.Join(boot.sourcePath, "services", "api", "tmp", "self-signed.pem"), // TODO: root ca
23 "SSLKEY": filepath.Join(boot.sourcePath, "services", "api", "tmp", "self-signed.key"), // TODO: root ca
24 "ACCESSLOG": filepath.Join(boot.tempdir, "nginx_access.log"),
25 "ERRORLOG": filepath.Join(boot.tempdir, "nginx_error.log"),
26 "TMPDIR": boot.tempdir,
29 for _, cmpt := range []struct {
33 {"CONTROLLER", boot.cluster.Services.Controller},
34 {"KEEPWEB", boot.cluster.Services.WebDAV},
35 {"KEEPWEBDL", boot.cluster.Services.WebDAVDownload},
36 {"KEEPPROXY", boot.cluster.Services.Keepproxy},
37 {"GIT", boot.cluster.Services.GitHTTP},
38 {"WS", boot.cluster.Services.Websocket},
40 vars[cmpt.varname+"PORT"], err = internalPort(cmpt.svc)
42 return fmt.Errorf("%s internal port: %s (%v)", cmpt.varname, err, cmpt.svc)
44 vars[cmpt.varname+"SSLPORT"], err = externalPort(cmpt.svc)
46 return fmt.Errorf("%s external port: %s (%v)", cmpt.varname, err, cmpt.svc)
49 tmpl, err := ioutil.ReadFile(filepath.Join(boot.sourcePath, "sdk", "python", "tests", "nginx.conf"))
53 conf := regexp.MustCompile(`{{.*?}}`).ReplaceAllStringFunc(string(tmpl), func(src string) string {
57 return vars[src[2:len(src)-2]]
59 conffile := filepath.Join(boot.tempdir, "nginx.conf")
60 err = ioutil.WriteFile(conffile, []byte(conf), 0755)
65 if _, err := exec.LookPath(nginx); err != nil {
66 for _, dir := range []string{"/sbin", "/usr/sbin", "/usr/local/sbin"} {
67 if _, err = os.Stat(dir + "/nginx"); err == nil {
68 nginx = dir + "/nginx"
73 return boot.RunProgram(ctx, ".", nil, nil, nginx,
74 "-g", "error_log stderr info;",
75 "-g", "pid "+filepath.Join(boot.tempdir, "nginx.pid")+";",