Fixing backend URLs

Dang Tung tungcnw at gmail.com
Fri Sep 24 06:48:16 CEST 2010


Thanks for fast reply,

but  I pasted wrong, actually when I remove these block, it doesn't work

Here my configure again:

sub vcl_recv {

    # Host header check.
    # * Check if we recognize the domain used
    # * Normalize host headers to limit cache usage
    # * Rewrite URL for the virtual host monster
    # Return an error for other requests.


    # cache multimedia
    #if (req.request == "GET" && req.url ~ "\.(jpg|jpeg|gif|ico)$") {
    #  lookup;
    #}

    # cache CSS and JS files
    if (req.request == "GET" && req.url ~ "\.(css|js)$") {
    lookup;
    }

    # do not cache POST requests
    if (req.request == "POST") {
        pipe;
    }

    if (req.request != "GET" && req.request != "HEAD") {

    # figure out if you are allowed to purge stuff from cache
        if (req.request == "PURGE") {
            if (!client.ip ~ purge) {
                error 405 "Not allowed.";
            }
            lookup;
        }

    # else just pass it along
    pipe;
    }

    if (req.http.Authenticate || req.http.Authorization) {
        pass;
    }
}

sub vcl_hit {
  if (req.request == "PURGE") {
    set obj.ttl = 0s;
    error 200 "Purged.";
  }
}

sub vcl_miss {
  if (req.http.If-Modified-Since) {
    pass;
  }

  if (req.request == "PURGE") {
    error 404 "Not in cache.";
  }
}

sub vcl_fetch {
 if (beresp.status == 301 || beresp.status == 302)
 {
   set beresp.http.Location = regsub(beresp.http.Location,
"^(\w+://[^/]+):\d+", "\1");
 }
}


Many thanks and regards

On Fri, Sep 24, 2010 at 11:35 AM, Michael Alger <varnish at mm.quex.org> wrote:

> On Fri, Sep 24, 2010 at 11:21:18AM +0700, Dang Tung wrote:
> >
> > It's not work for me, may be my configurations are wrong, could anyone
> help
> > me please. Here's my configuration:
> >
> > sub vcl_fetch {
> >      if (!beresp.cacheable) {
> >          return (pass);
> >      }
> >      if (beresp.http.Set-Cookie) {
> >          return (pass);
> >      }
> >      return (deliver);
>
> Here you are returning from vcl_fetch(), so the following code will
> never be executed. You should move that return statement to be the
> last in the function.
>
> >  if (beresp.status == 301 || beresp.status == 302)
> >  {
> >    set beresp.http.Location = regsub(beresp.http.Location,
> "^(\w+://[^/]+):\d+", "\1");
> >  }
> > }
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> http://lists.varnish-cache.org/mailman/listinfo/varnish-misc
>



-- 
Nguyen Dang Tung
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20100924/d66d8a8e/attachment-0003.html>


More information about the varnish-misc mailing list