-1

I'm trying to have a Varnish ESI caching on my local setup.

I did create a sample html file called index.html.

<html>
<body>

    <h1>Hello!!~~</h1>
    <esi:include src="http://noshitdebian.local/paa.txt"/>
    <esi:include src="footer.txt"/>
</body>
</html>

The first ESI tag will source to my another local server while the second ESI tag source is present locally in my webserver.

This is the response I got, 404 on the remote and successful for local

It looks like varnish process the request on defined backend server, here's the log.

https://pastebin.com/7t03A9nP

My varnish VCL code for ESI. https://pastebin.com/kaVmrXqw

How can I tell varnish to lookup that resource on remote server?

1 Answers1

0

It looks like varnish process the request on defined backend server

That's what Varnish always does. Using a URL with a domain in esi src has the effect of setting the Host header in the ESI request to the domain, but does not create a new backend. The request is routed only to a backend you've defined.

How can I tell varnish to lookup that resource on remote server?

Define the backend you want to use, in this case with the colorfully-named host noshitdebian.local. Then write a rule in VCL that will route a request to that backend, presumably when the Host header is set to that value.

  • Yeah right, but if my resources is on my S3 bucket, should I define a backend block for it? – nejnej25 Aug 19 '20 at 00:31
  • @nejnej25 I don't know AWS well enough to understand exactly what you mean by "resources on my S3 bucket". But since you have to define a backend to get Varnish to route a request to there, you'll have to have a way to make a backend out of your "resource on your S3 bucket." By the looks of your example, it's apparently the domain name that specifies the target, so maybe you can use that in the `.host` field of your backend. – slimhazard Aug 19 '20 at 07:55