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

In some setup, I saw someone put haproxy / varinish behind nginx, and forward the requests to backend (e.g. Passenger)


Nginx <---> HaProxy / Varinish <----> Passenger / Apache

I never understand why not put HaProxy / Varinish to the edge directly, any advantages?

share|improve this question
How about just asking the people who did the setup ... ? They can tell you for sure and why, go into details, the rest of us can only make educated guesses (-: – KM. Jan 7 '12 at 14:55
up vote 1 down vote accepted

It's possible they did it to handle SSL traffic. This seems unlikely, and there would be mroe efficient methods such as stunnel.

Another maybe is to handle static content before passing on to a dynamic backend.

share|improve this answer
Stunnel is not hugely more efficient and ngnix has the big advantage of having config files similar to apache's style (admins usually like to bend their mind around a problem, but hate to see a solution screw up because of unfamiliar syntax). Plus, haproxy is capable of buffering the users' uploads - something that surely comes handy if you have to take down some of your backend servers for maintenance occasionally but need an easy way to ensure that you do not break potentially long-living low-bandwidth POST connections. – the-wabbit Jan 8 '12 at 0:20
have to say, i had never thought of the buffered uploads point. i can see some very useful scenarios for that! i had no queries with using haproxy in front of the site, it was using nginx in front of haproxy that confused me! i mean, why BOTH? – SimonJGreen Jan 8 '12 at 11:34
because haproxy alone would not handle the buffering for backend servers (it would pass on the connection and if a backend server goes down, the connection obviously breaks) and ngnix is not as good when it comes to load balancing. – the-wabbit Jan 8 '12 at 11:45
i see. in that case, good use case :) quite niche though! – SimonJGreen Jan 8 '12 at 12:16

nGinx is event-driven and Varnish uses threads so the former should scale better (in theory). You could use Varnish to handle more complex caching cases and have nGinx handle the straight forward stuff.

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.