Mapping a domain to URI of drupal

Jerais Al-Jeraisy jerais at kernel.com.sa
Tue Jul 27 11:54:19 CEST 2010


Hello,
We have varnish-2.0.6 on CentOS 5.5 in front of Apache & drupal, and we
tried to map the domain ww.xx.yy.zz to a drupal URI, like /websites/a/b/c,
so any one can hit ww.xx.yy.zz directly insted of wiritng
ww.xx.yy.zz/websites/a/b/c.
it works fine for the first time, but the next time i hit the same URL, it
directs me to the main page of drupal, not to the URI, and i should delete
all my temp files to get it to work again.

here's the config file:

backend default {
  .host = "127.0.0.1";
  .port = "8080";
}
sub vcl_recv {

    if (req.request != "GET" &&
      req.request != "HEAD" &&
      req.request != "PUT" &&
      req.request != "POST" &&
      req.request != "TRACE" &&
      req.request != "OPTIONS" &&
      req.request != "DELETE") {
        return (pipe);
    }

    if (req.request != "GET" && req.request != "HEAD") {
        return (pass);
    }
    if (req.http.Authorization || req.http.Cookie) {
        return (pass);
    }

   if (req.http.host ~ "^ww\.xx\.yy\.zz$") {
        set req.url = "/websites/a/b/c/";
    }
    return (lookup);
}
sub vcl_pipe {
    return (pipe);
}
sub vcl_pass {
    return (pass);
}
sub vcl_hash {
    set req.hash += req.url;
    if (req.http.host) {
        set req.hash += req.http.host;
    } else {
        set req.hash += server.ip;
    }
    return (hash);
}
sub vcl_hit {
    if (!obj.cacheable) {
        return (pass);
    }
    return (deliver);
}
sub vcl_miss {
    return (fetch);
}
sub vcl_fetch {
    if (!obj.cacheable) {
        return (pass);
    }
    if (obj.http.Set-Cookie) {
        return (pass);
    }
    set obj.prefetch =  -30s;
    return (deliver);
}
sub vcl_deliver {
    return (deliver);
}
sub vcl_discard {
    return (discard);
}
sub vcl_prefetch {
    return (fetch);
}
sub vcl_timeout {
    return (discard);
}
sub vcl_error {
    set obj.http.Content-Type = "text/html; charset=utf-8";
    synthetic {"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
    <title>"} obj.status " " obj.response {"</title>
  </head>
  <body>
    <h1>Error "} obj.status " " obj.response {"</h1>
    <p>"} obj.response {"</p>
    <h3>Guru Meditation:</h3>
    <p>XID: "} req.xid {"</p>
    <hr>
    <address>
       <a href="http://www.varnish-cache.org/">Varnish cache server</a>
    </address>
  </body>
</html>
"};
    return (deliver);
}


//JJ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20100727/ac1b9c03/attachment-0003.html>


More information about the varnish-misc mailing list