---
title: "Varnish, Apache2 och Edge Side Include (ESI)"
type: "forum-thread"
url: "https://www.webforum.nu/amne/webbservrar/186627-varnish-apache2-och-edge-side-include-esi"
topic: "Webbservrar"
topic_url: "https://www.webforum.nu/amne/webbservrar"
author: "jme"
published: "2011-04-10T16:16:04.000Z"
updated: "2011-04-10T16:53:04.000Z"
replies: 2
views: 1146
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/webbservrar/186627-varnish-apache2-och-edge-side-include-esi"
---

# Varnish, Apache2 och Edge Side Include (ESI)

## #1 — jme, 2011-04-10T16:16Z

Hej.

Nu har jag försökt länge med att få varnish, apache2 och ESI att fungera ihop men utan större framgång.

Finns det någon här som har erfarenhet av varnish och ESI?

Permalänk: https://www.webforum.nu/p/186627

## #2 — colione, 2011-04-10T16:23Z

Well, hur ser din varnish-conf ut? Hur skriver du ut esin?

Permalänk: https://www.webforum.nu/p/2274090

## #3 — jme, 2011-04-10T16:53Z

Jag kör med varnish 2.1.5.

```php
## Redirect requests to Apache, running on port 8000 on localhost
backend apache {
        .host = "127.0.0.1";
        .port = "9002";
}
## Fetch
sub vcl_fetch {
                ## Remove the X-Forwarded-For header if it exists.
        remove req.http.X-Forwarded-For;

                ## insert the client IP address as X-Forwarded-For. This is the normal IP address of the user.
        set    req.http.X-Forwarded-For = req.http.rlnclientipaddr;
                ## Added security, the "w00tw00t" attacks are pretty annoying so lets block it before it reaches our webserver
        if (req.url ~ "^/w00tw00t") {
                error 403 "Not permitted";
        }

        esi;  /* Do ESI processing */
        unset beresp.http.set-cookie;
        set beresp.ttl = 60s;

                ## Deliver the content
        return(deliver);
}

## Deliver
sub vcl_deliver {
                ## We'll be hiding some headers added by Varnish. We want to make sure people are not seeing we're using Varnish.
              ## Since we're not caching (yet), why bother telling people we use it?
        remove resp.http.X-Varnish;
        remove resp.http.Via;
        remove resp.http.Age;

                ## We'd like to hide the X-Powered-By headers. Nobody has to know we can run PHP and have version xyz of it.
        remove resp.http.X-Powered-By;
}
```

Sedan testade jag först med två filer, foo.html och foo2.html:

foo:html

\<esi:include src="/foo2.html" /\>

foo2.html:

bar

Jag testade även med 

\<esi:include src="http://localhost/foo2.html" /\>

Permalänk: https://www.webforum.nu/p/2274093

---

Tråden på webben: https://www.webforum.nu/amne/webbservrar/186627-varnish-apache2-och-edge-side-include-esi
