CDN subdomain handling (hiding) in Varnish

Alex Hooper ahooper at bmjgroup.com
Tue Apr 26 11:29:21 CEST 2011


Shibashish uttered:
> 2011/4/25 Roberto O. Fernández Crisial 
> <roberto.fernandezcrisial at gmail.com 
> <mailto:roberto.fernandezcrisial at gmail.com>>
> 
[snip]

> 
> Can I do a exact match on the cdn domain and redirect to the main 
> domain? i.e. "cdn.example.com <http://cdn.example.com>" gets directed to 
> www.example.com <http://www.example.com>, 
> but cdn.example.com/images/abc.jpg 
> <http://cdn.example.com/images/abc.jpg> should not be redirected. Or is 
> there a better way?


Hi,

What I do (with no claim that it's the canonical, or even a better, solution) is 
to put a rewrite rule on the origin server that says "if the request comes from 
the CDN caches and is not for (jpg|gif|js|css|whatever) then issue a permanent 
redirect to the canonical site".

So the CDN ends up storing pointers back to the canonical site for those 
resources you do not wish served from CDN. The result being that, even if a user 
does go to http://cdn.example.com/ they are bounced straight back to 
http://www.example.com/).

HTH, etc,

Alex.

-- 
Alex Hooper
Operations Team Leader, BMJ Group, BMA House, London WC1H 9JR
Tel: +44 (0) 20 7383 6049
http://group.bmj.com/

_______________________________________________________________________
The BMJ Group is one of the world's most trusted providers of medical information for doctors, researchers, health care workers and patients group.bmj.com.  This email and any attachments are confidential.  If you have received this email in error, please delete it and kindly notify us.  If the email contains personal views then the BMJ Group accepts no responsibility for these statements.  The recipient should check this email and attachments for viruses because the BMJ Group accepts no liability for any damage caused by viruses.  Emails sent or received by the BMJ Group may be monitored for size, traffic, distribution and content.  BMJ Publishing Group Limited trading as BMJ Group.  A private limited company, registered in England and Wales under registration number 03102371.  Registered office: BMA House, Tavistock Square, London WC1H 9JR, UK.
_______________________________________________________________________




More information about the varnish-misc mailing list