Skip to content

Commit

Permalink
[bugfix] fixed unable to establish a connection to nginx https port bug
Browse files Browse the repository at this point in the history
#1655 (#2218)

Co-authored-by: Logic <[email protected]>
Co-authored-by: tomsun28 <[email protected]>
  • Loading branch information
3 people authored Jul 14, 2024
1 parent 823430b commit 999b37e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ private HttpUriRequest createHttpRequest(NginxProtocol nginxProtocol) {
? 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions manager/src/main/resources/define/app-nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -99,6 +109,8 @@ metrics:
port: ^_^port^_^
# timeout
timeout: ^_^timeout^_^
# ssl
ssl: ^_^ssl^_^

- name: nginx_status
i18n:
Expand Down Expand Up @@ -173,6 +185,8 @@ metrics:
timeout: ^_^timeout^_^
# http url
url: /nginx-status
# ssl
ssl: ^_^ssl^_^

- name: req_status
i18n:
Expand Down Expand Up @@ -237,3 +251,5 @@ metrics:
timeout: ^_^timeout^_^
# http url
url: /req-status
# ssl
ssl: ^_^ssl^_^

0 comments on commit 999b37e

Please sign in to comment.