Using that answer: How to redirect traffic on port 80 to Tomcat port 8080 whilst still allowing the server to send/receive on port 80
I've configured my apache2 server to redirect some requests to glassfish on 8080:
<VirtualHost *:80>
(...)
ProxyPass /tomcat/ http://localhost:8080/
ProxyPassReverse /tomcat/ http://localhost:8080/
ProxyPass /tomcat-admin/ http://localhost:4848/
ProxyPassReverse /tomcat-admin/ http://localhost:4848/
</VirtualHost>
On http://my.server.org/tomcat/ , I can clearly see:
GlassFish Server 3.1.2
Your server is now running
but http://my.server.org/tomcat-admin/ returns a blank screen , but I can see the HTML source of the admin page, so I suppose that some resources cannot be loaded. How should I fix this ?
Another question: if my java web application use httpS, should I just add:
ProxyPass /tomcat-secure/ http://localhost:8443/
ProxyPassReverse /tomcat-secure/ http://localhost:8443/
</VirtualHost>
?
Unfortunately I don't know anything about that apache-proxy stuff. However, I had a similar problem and my workaround may help you to solve your issue.
I fully integrated tomcat into apache using
mod-jk
. Assuming you're using a Debian-based distro just installlibapache2-mod-jk
and configure the module in/etc/libapache2-mod-jk/workers.properties
. You may need something like this:These parameters define the connection between apache and tomcat. I told tomcat to only listen to
127.0.0.1
. But it should be fine to configure the module to speak to another IP and/or a different port if you need a standalone tomcat installation available without apache.Next step: Open
/etc/apache2/mods-available/jk.conf
and make sure that apache reads these properties:If that is done, the communication between apache and tomcat should work. Now you can create some hosts forwarding their requests to tomcat:
This virtual host will forward each request to the context
YourContext
at tomcat.ajp13_worker
is the worker-definition as previously configured in/etc/libapache2-mod-jk/workers.properties
(of course you can configure multiple workers for different IPs/ports) and theRewriteRule
rewrites the query to prefix it withYourContext
. So you also need the rewrite module, if it's not already enabled. Enable the modules and this host:and go for
http://your.host.tld/abc?some=query
. You'll hopefully end up with the same result as if you callhttp://your.host.tld:8080/YourContext/abc?some=query
.Hope that helps ;-)