This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new f88d606 consoleproxy: Fixes #2733 invalid consoleproxy url after
upgrade (#2734)
f88d606 is described below
commit f88d606acbc566e2f777a18d1b1f90db428162b4
Author: René Moser <[email protected]>
AuthorDate: Thu Jul 26 09:31:23 2018 +0200
consoleproxy: Fixes #2733 invalid consoleproxy url after upgrade (#2734)
Ensures we have a valid console proxy domain for protocol http even a *
setting is used. See #2733
---
core/src/com/cloud/info/ConsoleProxyInfo.java | 48 ++++++++++++++-------------
1 file changed, 25 insertions(+), 23 deletions(-)
diff --git a/core/src/com/cloud/info/ConsoleProxyInfo.java
b/core/src/com/cloud/info/ConsoleProxyInfo.java
index 16993d7..78cb877 100644
--- a/core/src/com/cloud/info/ConsoleProxyInfo.java
+++ b/core/src/com/cloud/info/ConsoleProxyInfo.java
@@ -35,38 +35,40 @@ public class ConsoleProxyInfo {
public ConsoleProxyInfo(boolean sslEnabled, String proxyIpAddress, int
port, int proxyUrlPort, String consoleProxyUrlDomain) {
this.sslEnabled = sslEnabled;
+ this.proxyPort = port;
+ this.proxyUrlPort = proxyUrlPort;
+ this.proxyAddress = this.formatProxyAddress(consoleProxyUrlDomain,
proxyIpAddress);
if (sslEnabled) {
- StringBuffer sb = new StringBuffer();
- if (consoleProxyUrlDomain.startsWith("*")) {
- sb.append(proxyIpAddress);
- for (int i = 0; i < proxyIpAddress.length(); i++)
- if (sb.charAt(i) == '.')
- sb.setCharAt(i, '-');
- sb.append(consoleProxyUrlDomain.substring(1));//skip the *
- } else {
- //LB address
- sb.append(consoleProxyUrlDomain);
- }
- proxyAddress = sb.toString();
- proxyPort = port;
- this.proxyUrlPort = proxyUrlPort;
-
proxyImageUrl = "https://" + proxyAddress;
- if (proxyUrlPort != 443)
+ if (proxyUrlPort != 443) {
proxyImageUrl += ":" + this.proxyUrlPort;
- } else {
- proxyAddress = proxyIpAddress;
- if (StringUtils.isNotBlank(consoleProxyUrlDomain)) {
- proxyAddress = consoleProxyUrlDomain;
}
- proxyPort = port;
- this.proxyUrlPort = proxyUrlPort;
+ } else {
proxyImageUrl = "http://" + proxyAddress;
- if (proxyUrlPort != 80)
+ if (proxyUrlPort != 80) {
proxyImageUrl += ":" + proxyUrlPort;
+ }
+ }
+ }
+
+ private String formatProxyAddress(String consoleProxyUrlDomain, String
proxyIpAddress) {
+ StringBuffer sb = new StringBuffer();
+ // Domain in format *.example.com, proxy IP is 1.2.3.4 -->
1-2-3-4.example.com
+ if (consoleProxyUrlDomain.startsWith("*")) {
+ sb.append(proxyIpAddress.replaceAll("\\.", "-"));
+ sb.append(consoleProxyUrlDomain.substring(1)); // skip the *
+
+ // Otherwise we assume a valid domain if config not blank
+ } else if (StringUtils.isNotBlank(consoleProxyUrlDomain)) {
+ sb.append(consoleProxyUrlDomain);
+
+ // Blank config, we use the proxy IP
+ } else {
+ sb.append(proxyIpAddress);
}
+ return sb.toString();
}
public String getProxyAddress() {