webForumDet fria alternativet
Logga in / Bli medlem

Varnish, Apache2 och Edge Side Include (ESI)

Webbservrar

2 svar · 1 146 visningar · startad av jme

Medlem sedan maj 20012 237 inlägg
Trådstart#1

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?

Medlem sedan juni 20014 421 inlägg
#2

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

Medlem sedan maj 20012 237 inlägg
#3

Jag kör med varnish 2.1.5.

## 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" />

298 ms totalt · 4 externa anrop · v20260731065814-full.51f67c91
142 ms — deklarationer (db)
0 ms — hämta statistik (cache)
153 ms — hämta tråd, inlägg och bilagor (db)
142 ms — ändringar (db)