Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am just trying to get varnish in front of Glassfish instances, which are load balanced with the mod_jk connector in Apache. But I don't really know how to combine them. The AJP_Ports for instances are e.g. 8009, 8010, 8011. I am not able to access them via the browser, but I can access the normal HTTP ports like 28080. For the 28080 ports I can put varnish in front of them. For the AJP_ports it's not possible.

Do you know a way where I can load balancer glassfish instances which are cached using varnish? Is it impossible to do this with mod_jk?

share|improve this question
Can you put apache between varnish and your app server? So you have incoming --> varnish --> apache --> app server? – KM. Jan 31 '12 at 18:10
Hmm. I've thought that the problem is here, that varnish doesn't support https. But doesn't it make sense to put: incoming --> apache --> load balancer --> varnish --> appserver instance ? – High6 Jan 31 '12 at 21:15
Ah, but you didn't mention https (-: Typically, you'd want varnish in front of apache. Varnish caches are fast (memory or file) which makes it better at taking a large amounts of incoming traffic than apache or your app server. This eases the load on the components behind it, like apache, app servers, db, etc. What is the reasoning behind your setup (curious mostly)? – KM. Feb 1 '12 at 16:00
The idea is to get less load on the application server and cache some responses. – High6 Feb 1 '12 at 17:33
So you're using apache+mod_jk as a load balancer? Here apache will take the hit first, which under high load could be problematic. Varnish in front of apache should be able do the same thing and do it better; you can also use Varnsh as a load balancer ... but you know your setup best and you have to maintain it (-: Looks like you go it working. Good luck! – KM. Feb 1 '12 at 19:31
up vote 0 down vote accepted

Ok, what I have done now is to load balance via nginx (see this example). Varnish is running on each instance server in front of the Glassfish instance. And nginx balances over this varnish servers. I don't know if this is the perfect setup but it seems to work.

share|improve this answer

Your Answer


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.