diff --git a/src/core/nginx.go b/src/core/nginx.go index 2b11d26a9..164a89302 100644 --- a/src/core/nginx.go +++ b/src/core/nginx.go @@ -23,8 +23,9 @@ import ( ) const ( - withWithPrefix = "with-" - withModuleSuffix = "module" + withWithPrefix = "with-" + withModuleSuffix = "module" + defaultNginxOssPrefix = "/usr/local/nginx" ) var ( @@ -576,7 +577,9 @@ func (n *NginxBinaryType) getNginxInfoFromBuffer(exePath string, buffer *bytes.B } } - if info.cfgf["prefix"] != nil { + if info.cfgf["prefix"] == nil { + info.prefix = defaultNginxOssPrefix + } else { info.prefix = info.cfgf["prefix"].(string) } diff --git a/src/core/nginx_test.go b/src/core/nginx_test.go index 8381a40b7..9d2c57d02 100644 --- a/src/core/nginx_test.go +++ b/src/core/nginx_test.go @@ -202,6 +202,23 @@ func TestGetNginxInfoFromBuffer(t *testing.T) { modulesPath: "", }, }, + { + name: "custom nginx install no config args", + input: `nginx version: nginx/1.19.10 + TLS SNI support enabled + configure arguments: `, + expectedNginxInfo: &nginxInfo{ + prefix: "/usr/local/nginx", + confPath: "/usr/local/nginx/conf/nginx.conf", + version: "1.19.10", + plusver: "", + source: "", + cfgf: map[string]interface{}{}, + configureArgs: []string{""}, + loadableModules: nil, + modulesPath: "", + }, + }, } err := os.Mkdir("/tmp/modules", 0700) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go index 2b11d26a9..164a89302 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go @@ -23,8 +23,9 @@ import ( ) const ( - withWithPrefix = "with-" - withModuleSuffix = "module" + withWithPrefix = "with-" + withModuleSuffix = "module" + defaultNginxOssPrefix = "/usr/local/nginx" ) var ( @@ -576,7 +577,9 @@ func (n *NginxBinaryType) getNginxInfoFromBuffer(exePath string, buffer *bytes.B } } - if info.cfgf["prefix"] != nil { + if info.cfgf["prefix"] == nil { + info.prefix = defaultNginxOssPrefix + } else { info.prefix = info.cfgf["prefix"].(string) }