Skip to content

Commit

Permalink
fixup for https proxy with basic authn (#1202)
Browse files Browse the repository at this point in the history
* fix for the https proxy with basic authn
  • Loading branch information
ezhang-px committed Aug 11, 2023
1 parent e1bebf6 commit 72b8d40
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 61 deletions.
7 changes: 1 addition & 6 deletions deploy/ccm/envoy-config-collector-custom-https-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,4 @@ static_resources:
address:
socket_address:
address: CUSTOM_PROXY_ADDRESS
port_value: CUSTOM_PROXY_PORT
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: CUSTOM_PROXY_ADDRESS
port_value: CUSTOM_PROXY_PORT
7 changes: 1 addition & 6 deletions deploy/ccm/envoy-config-register-custom-https-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,4 @@ static_resources:
address:
socket_address:
address: CUSTOM_PROXY_ADDRESS
port_value: CUSTOM_PROXY_PORT
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: CUSTOM_PROXY_ADDRESS
port_value: CUSTOM_PROXY_PORT
7 changes: 1 addition & 6 deletions deploy/ccm/envoy-config-rest-custom-https-proxy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,4 @@ static_resources:
address:
socket_address:
address: CUSTOM_PROXY_ADDRESS
port_value: CUSTOM_PROXY_PORT
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: CUSTOM_PROXY_ADDRESS
port_value: CUSTOM_PROXY_PORT
10 changes: 2 additions & 8 deletions drivers/storage/portworx/component/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,14 +1059,8 @@ func CanAccessArcusRegisterEndpoint(
}
client := &http.Client{}
if proxy != "" {
if strings.Contains(strings.ToLower(proxy), "@") {
if !strings.HasPrefix(strings.ToLower(proxy), "https://") {
proxy = "https://" + proxy
}
} else {
if !strings.HasPrefix(strings.ToLower(proxy), "http://") {
proxy = "http://" + proxy
}
if !strings.HasPrefix(strings.ToLower(proxy), "http://") {
proxy = "http://" + proxy
}
proxyURL, err := url.Parse(proxy)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,3 @@ data:
socket_address:
address: hostname
port_value: 1234
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: hostname
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,3 @@ data:
socket_address:
address: hostname
port_value: 1234
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: hostname
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,3 @@ data:
socket_address:
address: hostname
port_value: 1234
transport_socket:
name: envoy.transport_sockets.tls
typed_config:
"@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
sni: hostname
6 changes: 0 additions & 6 deletions drivers/storage/portworx/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,6 @@ func GetPxProxyEnvVarValue(cluster *corev1.StorageCluster) (string, string) {
for _, env := range cluster.Spec.Env {
key, val := env.Name, env.Value
if key == EnvKeyPortworxHTTPSProxy {
// If http proxy is specified in https env var, treat it as a http proxy endpoint
if strings.HasPrefix(val, "http://") {
logrus.Warnf("using endpoint %s from environment variable %s as a http proxy endpoint instead",
val, EnvKeyPortworxHTTPSProxy)
return EnvKeyPortworxHTTPProxy, val
}
return EnvKeyPortworxHTTPSProxy, val
} else if key == EnvKeyPortworxHTTPProxy {
httpProxy = val
Expand Down
16 changes: 2 additions & 14 deletions pkg/util/test/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3484,14 +3484,8 @@ func CanAccessArcusRegisterEndpoint(

client := &http.Client{}
if proxy != "" {
if strings.Contains(strings.ToLower(proxy), "@") {
if !strings.HasPrefix(strings.ToLower(proxy), "https://") {
proxy = "https://" + proxy
}
} else {
if !strings.HasPrefix(strings.ToLower(proxy), "http://") {
proxy = "http://" + proxy
}
if !strings.HasPrefix(strings.ToLower(proxy), "http://") {
proxy = "http://" + proxy
}
proxyURL, err := url.Parse(proxy)
if err != nil {
Expand Down Expand Up @@ -3553,12 +3547,6 @@ func GetPxProxyEnvVarValue(cluster *corev1.StorageCluster) (string, string) {
for _, env := range cluster.Spec.Env {
key, val := env.Name, env.Value
if key == EnvKeyPortworxHTTPSProxy {
// If http proxy is specified in https env var, treat it as a http proxy endpoint
if strings.HasPrefix(val, "http://") {
logrus.Warnf("Using endpoint [%s] from environment variable [%s] as a http proxy endpoint instead",
val, EnvKeyPortworxHTTPSProxy)
return EnvKeyPortworxHTTPProxy, val
}
return EnvKeyPortworxHTTPSProxy, val
} else if key == EnvKeyPortworxHTTPProxy {
httpProxy = val
Expand Down

0 comments on commit 72b8d40

Please sign in to comment.