AWS Varnish calls inhouse Varnish

23 views Asked by At

Varnish calls inhouse Varnish

Long time we use a Varnish inhouse, which runs very well.

We began to switch our code to AWS. Also, we installed a Varnish in AWS which works as expected. Now I would like to access some code from AWS Varnish via inhouse Varnish and the trouble starts.

In AWS:

sub vcl_recv {
[...]
  if ( req.http.host == "aws.myhost.com" ) {
    if ( req.url ~ "^/marker/" ) {
      call marker_rules;                # will be called @ "aws.myhost.com/marker/*"
    }
  }
[...]
}

sub marker_rules {
  # as long as I do not use port 80/443 everything looks ok.
  set req.backend_hint = marker_service.backend(client.identity);

  # I would like to access the inhouse.myhost.com URL with Parameters on port 80
  # and this results in status 404
  return (pass);
}


# will called in default.vcl in vcl_init()
sub marker_init {
  new marker_service = directors.hash();
  marker_service.add_backend(marker_worker_1, 1.0);
}


backend marker_worker_1 {
  .host "inhouse.myhost.com";
  .port "80";
  .probe = marker_health;   # works as expected, will call every 5s
}


# The probe works as expected
probe marker_health {
  .url = "/marker/actuator/health";
  .interval = 15s;
  # also set: timeout 5s, window 3, threshold 2, initial 2, expected_response = 200;
}

This shorted code should show how it is implemented. The probe from AWS Varnish will call the inhouse.myhost.com every 15s on port 80 and earned the expected status 200. This is also seen in the varnish log of the inhouse varnish.

But when I do a curl -v -k "https://aws.myhost.com/marker/actuator/health" I get status 404.

What should I observe, to simply call the inhouse URLs by the AWS Varnish?

I can't move the Code behind the inhouse Varnish to AWS.

Could it be, that the set req.backend_hint... is in trouble with the same domain name, only the subdomain name is something else.

I'm using varnish 6.5

1

There are 1 answers

0
Lars On

My mistake.

If you switch the domain name by req.backend_hint... the current Varnish will move the call to the other server. If there runs also a Varnish, the call comes with the original domain name.

In my case I had to create a new sub domain "inhousefromaws.myhost.com" and handle it by the "inhouse Varnish" just for answer the probes. The original "inhouse.myhost.com" has to stay.

The old domain name "inhouse.myhost.com" has to switch to AWS. The .probe URL of the AWS Varnish has to set to "inhousefromaws.myhost.com". Also the handle of the "inhouse.myhost.com" domain has to add to AWS Varnish, and switch to new "inhousefromaws.myhost.com" by req.backend_hint...

The problem was, that on the old varnish the domain is not changed.