summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/utils/HttpUtils.java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2012-09-20 09:41:28 -0400
committerJames Moger <james.moger@gitblit.com>2012-09-20 09:41:28 -0400
commitc558deef274d838aae5c0366ff7dc2ebce27a981 (patch)
tree33b0b6ec6183fcf5c676168659fe87185e1d0876 /src/com/gitblit/utils/HttpUtils.java
parent33622b7acfa037d0218dd7a9d62b4831015768f3 (diff)
downloadgitblit-c558deef274d838aae5c0366ff7dc2ebce27a981.tar.gz
gitblit-c558deef274d838aae5c0366ff7dc2ebce27a981.zip
Support X-Forwarded-Context for subdomain proxy configs (issue 135)
Diffstat (limited to 'src/com/gitblit/utils/HttpUtils.java')
-rw-r--r--src/com/gitblit/utils/HttpUtils.java16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/com/gitblit/utils/HttpUtils.java b/src/com/gitblit/utils/HttpUtils.java
index 3903f8c7..ad7d58c1 100644
--- a/src/com/gitblit/utils/HttpUtils.java
+++ b/src/com/gitblit/utils/HttpUtils.java
@@ -67,6 +67,20 @@ public class HttpUtils {
}
}
+ String context = request.getContextPath();
+ String forwardedContext = request.getHeader("X-Forwarded-Context");
+ if (forwardedContext != null) {
+ forwardedContext = request.getHeader("X_Forwarded_Context");
+ }
+ if (!StringUtils.isEmpty(forwardedContext)) {
+ context = forwardedContext;
+ }
+
+ // trim any trailing slash
+ if (context.length() > 0 && context.charAt(context.length() - 1) == '/') {
+ context = context.substring(1);
+ }
+
StringBuilder sb = new StringBuilder();
sb.append(scheme);
sb.append("://");
@@ -75,7 +89,7 @@ public class HttpUtils {
|| ("https".equals(scheme) && port != 443)) {
sb.append(":" + port);
}
- sb.append(request.getContextPath());
+ sb.append(context);
return sb.toString();
}
}