Using Varnish and HAProxy on the same server

  • Posted July 11, 2014

Hi there, I have Apache2 and Varnish on the same server, and I want to protect better my server against DDOS attacks. For this, I found HAProxy, and I would like to know if its a god idea to put Varnish and HAProxy on the same server ? I have 2Gb ram and 4 cores


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Thanks Nasser

Thank you so much for your response Kamal. I have one more question, do you think that will slow down my website to put 2 reverses proxy in front of my website ?

I’ve never used Varnish myself but you certainly can run both on the same server. To do that, you need to free up port 80 for HAProxy and bind Varnish to another port.

Edit /etc/default/varnish and replace DAEMON_OPTS="-a :80 \ with DAEMON_OPTS="-a :8080 \. If Apache2 is listening on port 8080, you can configure Varnish to listen on another port such as 8888 or whatever port you like.

Then, install HAProxy and configure it to listen on port 80 and reverse proxy connections to where 8080 is the port that Varnish is listening on.

Keep in mind that HAProxy isn’t designed to protect from DDoS attacks but it can be configured to help in doing so.