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