Apache in front of JSF Apache in front of JSF apache apache

Apache in front of JSF


The JSF ResourceHandler emits URLs with the <contextPath>/javax.faces.resource/ route, albeit indirectly through the ScriptRenderer, StyleSheetRenderer etc.

Since you're omitting the app name (context Path) in the ProxyPass directive, you'll need to use a URL rewriter to omit the URLs before they're served to the browser. Refer the answers in the related question on how to achieve this.


I use multiple ProxyPass and ProxyPassReverse entries to accommodate for the different context paths JSF might spit out. The following is typically my default for every domain (ServerName)...

<VirtualHost 127.0.0.1:8080>    ServerAdmin email@email.com    DocumentRoot "/"    ServerName "dev.mydomain.com"    ProxyPass /MyApp/ ajp://127.0.0.1:8009/MyApp/    ProxyPassReverse /MyApp/ http://127.0.0.1:80/MyApp/    ProxyPass /MyApp ajp://127.0.0.1:8009/MyApp/    ProxyPassReverse / http://127.0.0.1:80    ProxyPass / ajp://127.0.0.1:8009/MyApp/    ProxyPassReverse / http://127.0.0.1:80/     </VirtualHost>

The above configuration will allow access to the web app using any of the following URIs:

http://dev.myapp.com/MyApp/http://dev.myapp.com/MyApphttp://dev.myapp.com/

Therefore, http://dev.myapp.com/javax.faces.resource/example.css would hit the last rule and be routed to http://dev.myapp.com/MyApp/javax.faces.resource/example.css. Additionally, http://dev.myapp.com/MyApp/javax.faces.resource/example.css would hit the first rule and pass through as is.

NOTES:

  1. The order is important! These rules will be processed top down. If you put the ProxyPass for '/' first then the other conditions would never get processed. Since every URI has a / after the host name, every request would be processed with that condition... which is why the / condition should always go last.
  2. I highly recommend using the Apache JServ Protocol (ajp) Connector (instead of HTTP). It's built into Apache and JBOSS, it's easy to turn on and it significantly improves performance... especially if there's any kind of binary data (images) being routed. https://docs.jboss.org/jbossweb/2.1.x/config/ajp.html


Ran into the same problem and didn't found a way to configure an apache server either.

If you just want to tidy up your URL I can recommend URLRewriteFilter this helped me in that case.

Hope this helpes, have Fun!