Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>

?

share|improve this question
    
What do your apache logs say? –  ProfessionalAmateur Jan 9 '13 at 18:17

1 Answer 1

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 install libapache2-mod-jk and configure the module in /etc/libapache2-mod-jk/workers.properties. You may need something like this:

worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13

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:

JkWorkersFile /etc/libapache2-mod-jk/workers.properties

If that is done, the communication between apache and tomcat should work. Now you can create some hosts forwarding their requests to tomcat:

<VirtualHost *:80>
    [...]
    ServerName your.host.tld
    [...]
    RewriteEngine on
    RewriteRule ^/(.*)$ /YourContext/$1 [L,PT]
    JkMount /* ajp13_worker
    [...]
</VirtualHost>

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 the RewriteRule rewrites the query to prefix it with YourContext. So you also need the rewrite module, if it's not already enabled. Enable the modules and this host:

a2enmod jk
a2enmod rewrite
a2ensite 007-what-ever-host
service apache2 restart
service tomcat7 restart

and go for http://your.host.tld/abc?some=query. You'll hopefully end up with the same result as if you call http://your.host.tld:8080/YourContext/abc?some=query.

Hope that helps ;-)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.