Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Panel
borderStylesolid
titleTable of contents
Table of Contents
minLevel1

...

Running Wicket Behind A Front End Proxy

...

Many organisations choose to hide their web apps behind some kind of front-end proxy server. There are various ways to set this up. For example, you can set up mod_proxy in an Apache server host configuration like so:

Code Block
ProxyPass /<contextPath> http://appserver.company.com:8080/<contextPath>
ProxyPassReverse /<contextPath> http://appserver.company.com:8080/<contextPath>
ProxyPassReverseCookiePath /<contextPath> /

Where <contextPath> is replaced by the context path you've deployed your wicket application under.

The

...

ProxyPass

...

directive causes request URLs to be proxied to the specified host.

The

...

ProxyPassReverse

...

directive causes 302 redirects from your app server to be rewritten to point to the front-end proxy instead, so they continue to work properly.

The ProxyPassReverseCookiePath directive (Apache 2.2+ only) rewrites cookie paths for you, so sessions work properly.

Why this doesn't always work

...

Code Block
<VirtualHost ordering.company.com>
  ProxyPass / http://appserver.company.com:8080/ordering/
  ProxyPassReverse / http://appserver.company.com:8080/ordering/
  # Apache 2.2+ only
  ProxyPassReverseCookiePath /ordering /
</VirtualHost>

<VirtualHost billing.company.com>
  ProxyPass / http://appserver.company.com:8080/billing/
  ProxyPassReverse / http://appserver.company.com:8080/billing/
  # Apache 2.2+ only
  ProxyPassReverseCookiePath /billing /
</VirtualHost>

The problem with this is that although requests get proxied across just fine, by default Wicket will construct absolute paths to links, resources, etc. using the context path that the wicket servlet is deployed under (e.g. /billing). For example, if your wicket servlet is mapped to accept requests to "/wicket", this means anchor href links might look like this: "/billing/wicket?foo".

...

How to fix Wicket-generated links

Wicket 1.2 and higher allows you to override the context path it uses to generate absolute paths for links, resources, etc. You can either do this in your web.xml file:

...

Code Block
getApplicationSettings().setContextPath("/");

Wicket 1.3 uses relative URLs, which neatly avoids this problem in the first place. Don't use setContextPath with Wicket 1.3, unless you're running a PortletApplication.

Using UTF-8 encoded URIs with mod_jk

In it's default configuration, mod_jk uses

Code Block

JkOptions +ForwardURICompat

which may probably cause problems (especially with Wicket's UrlCodingStrategies) when used with UTF-8 encoded URIs that contains special characters, like http://www.mysite.com/Mei%C3%9Fen/. So if you experience problems with UTF-8 encoded URIs or just want to have a fully UTF-8 compliant cycle, remove this option from the mod_jk configuration or use some other forwarding options documented here.