URL rewrite with Varnish

AD straightflush at gmail.com
Tue Apr 3 15:48:22 CEST 2012


Does your backend answer for the hostname mysite.domain.com in apache/nginx
?  You didnt indicate that you have virtualhosts setup and what the
hostname header needs to be in order for your origin to respond properly.


On Tue, Apr 3, 2012 at 9:35 AM, Rafał Zawierta <zawierta at gmail.com> wrote:

>
>
> W dniu 3 kwietnia 2012 15:25 użytkownik AD <straightflush at gmail.com>napisał:
>
> You should be able to easily rewrite the req.http.header value in vcl_recv
>>
>>  if (req.http.host == "mysite.domain.com") {
>>     set req.http.host = "10.0.0.10";
>>  }
>>
>> To Rafal's point, this will pass the Host header of 10.0.0.10 to your
>> backend. Make sure you backend is configured to be port 8888
>>
>> backend default {
>>      .host = "127.0.0.1";
>>      .port = "8888";
>>  }
>>
>> On Tue, Apr 3, 2012 at 9:07 AM, James Light <j.gareth.light at gmail.com>wrote:
>>
>>> On Apr 3, 2012 8:53 AM, "Rafał Zawierta" <zawierta at gmail.com> wrote:
>>> >
>>> > Hello,
>>> >
>>> > Is it possible to handle such case: my webapp is running on
>>> http://10.0.0.10:8888/content/site/EN.html and whole site is on base
>>> url: http://10.0.0.10:8888/content/site/.
>>> >
>>> > I want to make my site available via Varnish on url:
>>> http://mysite.mydomain.com/ - I want to remove whole stuff after / from
>>> url.
>>> >
>>> > Rule:
>>> > sub vcl_recv {
>>> > if (req.http.host ~ "^(www\.)?mysite\.mydomain\.com$" ) {
>>> >   set req.url = regsub(req.url, "^/content/site/", "/");
>>> > }
>>> > }
>>> >
>>> > isn't working at all.
>>> >
>>> > Regards
>>> > R.
>>>
>>
>
> Sorry AD, but I'm not sure if your tip is helpful.
> Once again: my backend server has ip 10.0.0.10, port 8888. It runs
> multiple apps, so if I type http://10.0.0.10:8888 i get default site
> http://10.0.0.10:8888/content/default/EN.html. Therefore I'd like varnish
> to point me to /content/site/EN.html AND to remove "content/site/" from
> URL.
> That's why passing http.host won't work at all.
>
> Regards
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20120403/0e5e6995/attachment-0001.html>


More information about the varnish-misc mailing list