CDN subdomain handling (hiding) in Varnish

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

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

> Can I do a exact match on the cdn domain and redirect to the main 
> domain? i.e. " <>" gets directed to 
> <>, 
> but 
> <> should not be redirected. Or is 
> there a better way?


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 they are bounced straight back to

HTH, etc,


Alex Hooper
Operations Team Leader, BMJ Group, BMA House, London WC1H 9JR
Tel: +44 (0) 20 7383 6049

The BMJ Group is one of the world's most trusted providers of medical information for doctors, researchers, health care workers and patients  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