Details
-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
1.0 B1
-
None
-
Tomcat 5.5.16 JDK 1.5.0_06-b05, Apache/2.0.55 with mod_proxy on Linux
Description
When running behind a reverse proxy using https (e.g. https://secure.domain.com/xwiki/bin/view/Main/) the links are not prefixed with https but with http. The reason is the XWikiServletURLFactory.getServerURL evaluating the x-forwarded-host header of mod_proxy.
Fix:
- a) add a second header to specify the scheme
- b) add a configuration flag to disable evaluation of the x-forwarded-host header (but I don't know what this will break)
I've tested and implemented a):
- add this line to apache vhost config:
RequestHeader set X-Request-Scheme https
- apply this patch to the XWikiServeltURLFactory
===================================================================
--- src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java (revision 975)
+++ src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java (working copy)
@@ -101,10 +101,13 @@
if (host!=null) {
int comaind = host.indexOf(',');
final String host1 = comaind>0 ? host.substring(0, comaind) : host;
- if (!host1.equals(""))
- return new URL("http://"+host1);
+ if (!host1.equals("")) {
+ String scheme = context.getRequest().getHeader("x-request-scheme");
+ scheme = scheme == null ? "http" : scheme;
+ return new URL(scheme + "://"+host1);
+ }
}
- }
+ }
if (xwikidb==null)
return serverURL;
Attachments
Issue Links
- duplicates
-
XWIKI-5386 URLs created behind a reverse proxy are absolute and don't preserve https protocol
-
- Closed
-
- is duplicated by
-
XWIKI-2502 XWiki creates URLs with http instead of https
-
- Closed
-
-
XWIKI-3407 https -> http silent switch
-
- Closed
-