问题
In Jboss AS 7:
Putting Apache in front of Jboss with this works fine:
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
So app is accessed by domain.com/app.
Problem appears when aiming for a clearer URL(Just domain.com):
ProxyPass / http://localhost:8080/app
ProxyPassReverse / http://localhost:8080/app
All javax.faces.resource are not delivered in the second case, because they don't use the war context URL.
Any idea how to get the faces resources in the second case? Maybe just move to mod_jk?
This answer about ResourceHandler, helps pretty much.
回答1:
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.
回答2:
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/MyApp
http://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:
- 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. - 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
回答3:
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!
来源:https://stackoverflow.com/questions/15203177/apache-in-front-of-jsf