How to run PrimeFaces behind reverse proxy in a subdomain? How to run PrimeFaces behind reverse proxy in a subdomain? apache apache

How to run PrimeFaces behind reverse proxy in a subdomain?


Using (or not using) AJP has no bearing on resolving this specific issue.

Primefaces internally uses context path variable to include CSS and Javascript resources. Even using AJP you will end up with:

/unwantedAppContext/javax.faces.resource/jquery/jquery.js.jsf?ln=primefaces

What you could do to resolve this add another proxy pass to handle the unwanted context. This may not be the best solution, but it works.

<VirtualHost *:80>    ServerName myapplication.myserverurl.org    ProxyPass /myapplication/ http://myserverurl.org:8080/myapplication/    ProxyPassReverse /myapplication/ http://myserverurl.org:8080/myapplication/    ProxyPass / http://myserverurl.org:8080/myapplication/    ProxyPassReverse / http://myserverurl.org:8080/myapplication/</VirtualHost>

The order of the pass matters.

This issue was also reported in the icefaces forumhttp://www.icesoft.org/JForum/posts/list/4433.page#sthash.h1qSqiYg.dpbs


It may be different depending on the application server but, as a main rule, you should use AJP for the proxying.
First step is to enable ajp modules depending on OS. Ubuntu looks like this.

sudo a2enmod proxy proxy_ajp

Step 2, change the proxy definition in the apache conf to something like:

ProxyPass / ajp://localhost:8009/myapplicationProxyPassReverse / ajp://localhost:8009/myapplication

Step 3 is to enable it on the application server. Again, it varies depending of the one you use. Tomcat has a commented out section in the server.xml. Glassfish has a check-box in the admin console and an asadmin command (but I can't remember it)


Consider using ProxyHTMLURLMap directive from mod_proxy_html module. This module manipulates output HTML links to be pointed to the right location. In your case all the links that tell http://myapplication.myserverurl.org/ need to be changed back to /, i.e.

ProxyHTMLURLMap http://myapplication.myserverurl.org/ /

This way you can modify any call-back links that are pointing to wrong location.