<div dir="ltr">Hai,<br><br>I configured varnish along with Apache as web server(2 web servers) and Haproxy as load load balancer. Varnish is working when there is only one web server.<br><br>The flow of rewuest is:<br><br>
Fist the request hits Varnish from varnish to Haproxy from here any one of the web server (web1 or web2)<br><br>My varnish configuration is below <br><br> backend default {<br> # Our default backend, i.e. the web server<br>
# You can use more than 1. See docs.<br> set backend.host = "<a href="http://0.0.0.0">0.0.0.0</a>";<br> set backend.port = "9999";<br> }<br><br> sub vcl_recv {<br> if (req.request != "GET" && req.request != "HEAD") {<br>
pipe;<br> }<br> if (req.http.Expect) {<br> pipe;<br> }<br> if (req.http.Authenticate || req.http.Cookie) {<br> pass;<br> }<br>
if (req.request == "GET") {<br> lookup;<br> }<br> else {<br> lookup;<br> }<br> }<br> sub vcl_pipe {<br> pipe;<br>
}<br><br> sub vcl_pass {<br> pass;<br> }<br><br> sub vcl_hash {<br> set req.hash += req.url;<br> set req.hash += req.http.host;<br> hash;<br>
}<br><br> sub vcl_hit {<br> if (!obj.cacheable) {<br> pass;<br> }<br> deliver;<br> }<br><br> sub vcl_miss {<br> fetch;<br> }<br>
sub vcl_fetch {<br> if (!obj.valid) {<br> error;<br> }<br> if (!obj.cacheable) {<br> pass;<br> }<br> insert;<br> }<br>
<br> sub vcl_deliver {<br> deliver;<br> }<br><br> sub vcl_timeout {<br> discard;<br> }<br><br> sub vcl_discard {<br> discard;<br> }<br><br>
<br><strong>Shahid</strong><br></div>