3

We have 2 file servers(Apache port-82) which is running under Load Balancer. And I have configured varnish successfully for a domain(imgs.site.com) in 2 servers(port-80) and its working properly when i put a host entry for the server but when i access it globally(through LB) it went Aborted request. I guess there is something missing in my configuration. Pls help.

Here is my vcl configuration and i have the same configuration in both file1 and file2 servers

backend default {
  .host = "127.0.0.1";
  .port = "82";
  .first_byte_timeout = 60s;
  .between_bytes_timeout = 60s;
}

sub vcl_recv {

    if (req.request != "GET" &&
         req.request != "HEAD" &&
         req.request != "PUT" &&
         req.request != "POST" &&
        req.request != "TRACE" &&
        req.request != "OPTIONS" &&
         req.request != "DELETE") {

  return (pipe);
 }



if (req.http.host == "imgs.site.com") {

       set req.http.host = "imgs.site.com";
       set req.backend = default;
       return (lookup);
  }

}

It may be a basic question and since we're new to varnish, we dont know how to solve it.

1 Answers1

0

So to clarify, you have a load balancer for domain imgs.site.com passing along requests to port 80 on two machines. Each of these is running varnish and routing requests back to themselves on port 82. If some new request gets routed to http server A, and then the same request comes in again later and gets routed to http server B, the second request will be as slow as the first and you'll end up with the same lookup cached on two machines, so you'd get better cache performance if you set up a single varnish and used it as your load balancer in a round-robin configuration.

But to solve it the way it is, you can get diagnostic information about how varnish is responding to a request by running varnishlog while the request comes in. You can further verify that a request from the varnish machine to its backend (in this case, itself) works by running from a shell on the varnish machine:

$ telnet 127.0.0.1 82

and if you see a success message, enter a basic GET command (with two returns afterward):

GET / HTTP/1.0

You can test more complex requests requiring authentication or POST payloads using wget or curl commands.

And of course, verify that the http server is receiving the request by checking the logs.

jaybrau
  • 403
  • 1
  • 3
  • 9