This is an automated email from the ASF dual-hosted git repository.
gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 999b37ec4 [bugfix] fixed unable to establish a connection to nginx
https port bug #1655 (#2218)
999b37ec4 is described below
commit 999b37ec4fce2fb404dd8518ba51edabe7646b3b
Author: kangli <[email protected]>
AuthorDate: Sun Jul 14 23:15:48 2024 +0800
[bugfix] fixed unable to establish a connection to nginx https port bug
#1655 (#2218)
Co-authored-by: Logic <[email protected]>
Co-authored-by: tomsun28 <[email protected]>
---
.../collector/collect/nginx/NginxCollectImpl.java | 7 ++++++-
.../common/entity/job/protocol/NginxProtocol.java | 5 +++++
manager/src/main/resources/define/app-nginx.yml | 16 ++++++++++++++++
3 files changed, 27 insertions(+), 1 deletion(-)
diff --git
a/collector/src/main/java/org/apache/hertzbeat/collector/collect/nginx/NginxCollectImpl.java
b/collector/src/main/java/org/apache/hertzbeat/collector/collect/nginx/NginxCollectImpl.java
index 91c02e778..dfb4f606d 100644
---
a/collector/src/main/java/org/apache/hertzbeat/collector/collect/nginx/NginxCollectImpl.java
+++
b/collector/src/main/java/org/apache/hertzbeat/collector/collect/nginx/NginxCollectImpl.java
@@ -149,7 +149,12 @@ public class NginxCollectImpl extends AbstractCollect {
? String.format("[%s]:%s", host, portWithUri)
: String.format("%s:%s", host, portWithUri);
- requestBuilder.setUri(CollectorConstants.HTTP_HEADER + baseUri);
+ boolean ssl = Boolean.parseBoolean(nginxProtocol.getSsl());
+ if (ssl){
+ requestBuilder.setUri(CollectorConstants.HTTPS_HEADER +
baseUri);
+ } else {
+ requestBuilder.setUri(CollectorConstants.HTTP_HEADER +
baseUri);
+ }
}
requestBuilder.addHeader(HttpHeaders.CONNECTION, "keep-alive");
diff --git
a/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NginxProtocol.java
b/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NginxProtocol.java
index 732caa938..422e49c1b 100644
---
a/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NginxProtocol.java
+++
b/common/src/main/java/org/apache/hertzbeat/common/entity/job/protocol/NginxProtocol.java
@@ -51,6 +51,11 @@ public class NginxProtocol {
*/
private String url;
+ /**
+ * Whether nginx uses link encryption ssl/tls, i.e. http or https
+ */
+ private String ssl = "false";
+
/**
* Validates the relevant parameters
* @return is invalid true or false
diff --git a/manager/src/main/resources/define/app-nginx.yml
b/manager/src/main/resources/define/app-nginx.yml
index 7cff1d7b5..bea9d5ed4 100644
--- a/manager/src/main/resources/define/app-nginx.yml
+++ b/manager/src/main/resources/define/app-nginx.yml
@@ -69,6 +69,16 @@ params:
required: true
# default value 6000
defaultValue: 6000
+ # field-param field key
+ - field: ssl
+ # name-param field display i18n name
+ name:
+ zh-CN: 启动SSL
+ en-US: SSL
+ # When the type is boolean, the frontend will display a switch for it.
+ type: boolean
+ # required-true or false
+ required: false
# collect metrics config list
metrics:
@@ -99,6 +109,8 @@ metrics:
port: ^_^port^_^
# timeout
timeout: ^_^timeout^_^
+ # ssl
+ ssl: ^_^ssl^_^
- name: nginx_status
i18n:
@@ -173,6 +185,8 @@ metrics:
timeout: ^_^timeout^_^
# http url
url: /nginx-status
+ # ssl
+ ssl: ^_^ssl^_^
- name: req_status
i18n:
@@ -237,3 +251,5 @@ metrics:
timeout: ^_^timeout^_^
# http url
url: /req-status
+ # ssl
+ ssl: ^_^ssl^_^
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]