Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Excerpt
hiddentrue

How to run Wicket behind a front end proxy server (e.g. Apache with mod_jk or mod_proxy)

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>

Where

...

<contextPath>

...

is replaced by the context path you've deployed your wicket application under.

...

Code Block
<VirtualHost ordering.company.com>
{panel}
  ProxyPass / http://appserver.company.com:8080/ordering/
  ProxyPassReverse / http://appserver.company.com:8080/ordering/
{panel}
</VirtualHost>

<VirtualHost billing.company.com>
{panel}
  ProxyPass / http://appserver.company.com:8080/billing/
  ProxyPassReverse / http://appserver.company.com:8080/billing/
{panel}
</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".

This works fine for development, but when you stick it behind your proxy, suddenly everything stops working, because you're trying to link to a non-existent

...

/billing

...

directory. So your page will show up fine, but any resource links won't work, and nothing will work if you click on it (you'll get 404s).

...

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
<servlet>
{panel}
  <servlet-name>wicket</servlet-name>
  <servlet-class>wicket.protocol.http.WicketServlet</servlet-class>
  <init-param>
    <param-name>applicationClassName</param-name>
    <param-value>com.company.app.YourWebApplication</param-value>
  </init-param>
  <init-param>
    <param-name>contextpath</param-name>
    <param-value>/</param-value>
  </init-param>
{panel}
</servlet>

...or in the

...

init()

...

method of your

...

Application

...

subclass like so:

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