{"id":12361,"date":"2014-03-24T14:25:24","date_gmt":"2014-03-24T08:55:24","guid":{"rendered":"https:\/\/2thenew.online\/blog\/?p=12361"},"modified":"2014-03-24T14:27:25","modified_gmt":"2014-03-24T08:57:25","slug":"caching-multiple-domain-with-varnish","status":"publish","type":"post","link":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/","title":{"rendered":"Caching Multiple Domain with Varnish"},"content":{"rendered":"<div>Varnish is an in-memory web accelerator server which helps \u00a0Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server.<\/div>\n<div><\/div>\n<div>\n<div>In our projects we are using Varnish to cache the static content and in some cases we are also using it for caching the \u00a0full pages in the memory. \u00a0Few days back we got a requirement to cache multiple domain.<\/div>\n<div><\/div>\n<div>Mentioned below are the steps that we followed to configure the same.<\/div>\n<\/div>\n<div><\/div>\n<div>\n<pre>File to edit : \"\/etc\/varnish\/default.vcl\"<\/pre>\n<\/div>\n<div>[shell]<br \/>\n## This allows to Setting up health check<br \/>\nprobe varnish_probe {<br \/>\n .url = &quot;\/ping&quot;;<br \/>\n .timeout = 2s;<br \/>\n .interval = 5m;<br \/>\n .window = 3;<br \/>\n .threshold = 1;<br \/>\n}<br \/>\n[\/shell]<br \/>\n[shell]<br \/>\nbackend web1 {<br \/>\n .host = &quot;site.abc.com&quot;;<br \/>\n .probe = varnish_probe;<br \/>\n}<\/p>\n<p>backend web2 {<br \/>\n .host = &quot;back.abc.com&quot;;<br \/>\n .probe = varnish_probe;<br \/>\n}<\/p>\n<p>backend web3 {<br \/>\n .host = &quot;site.abc.in&quot;;<br \/>\n .port = &quot;8080&quot;;<br \/>\n}<br \/>\n[\/shell]<\/p>\n<p>For one of the website we are also using &#8220;Directors&#8221; to group multiple backends, which gives us incresed performance and resilience.<\/p>\n<p>[shell]<br \/>\n## Following is a round robin director, which will be distributing the incoming requests on a round-robin basis. As we are also using the Health checks, so it will not send the incoming requests to unhealthy backend.<br \/>\ndirector prodweb round_robin {<br \/>\n { .backend = web1; }<br \/>\n { .backend = web2; }<br \/>\n}<br \/>\n[\/shell]<\/p>\n<p>Now we will edit the &#8220;vcl_recv&#8221; subroutine to hit the multiple backends as per our need.<\/p>\n<p>[shell]<br \/>\nsub vcl_rcv {<br \/>\n if ( req.http.host ~ &quot;^site.abc.com$&quot; || req.http.host ~ &quot;^back.abc.com$&quot;) {<br \/>\n  set req.backend = prodweb; \/\/ we are using the director prodweb<br \/>\n }<br \/>\n if (req.http.host ~ &quot;^site.abc.in$&quot;) {<br \/>\n  set req.bakend = web3;<br \/>\n }<br \/>\n}<br \/>\n[\/shell]<\/p>\n<\/div>\n<div>Now you can restart the varnish and test the same.<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Varnish is an in-memory web accelerator server which helps \u00a0Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it [&hellip;]<\/p>\n","protected":false},"author":90,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":30,"footnotes":""},"categories":[1174],"tags":[1072,1357,1356],"class_list":["post-12361","post","type-post","status-publish","format-standard","hentry","category-aws-2","tag-cache","tag-multiple-domain","tag-varnish"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"abhishek.tomar\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Caching Multiple Domain with Varnish | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Caching Multiple Domain with Varnish | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#article\",\"name\":\"Caching Multiple Domain with Varnish | TO THE NEW Blog\",\"headline\":\"Caching Multiple Domain with Varnish\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/abhishek-tomar\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-03-24T14:25:24+05:30\",\"dateModified\":\"2014-03-24T14:27:25+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#webpage\"},\"articleSection\":\"AWS, Cache, multiple domain, varnish\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/#listItem\",\"name\":\"AWS\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/#listItem\",\"position\":2,\"name\":\"AWS\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#listItem\",\"name\":\"Caching Multiple Domain with Varnish\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#listItem\",\"position\":3,\"name\":\"Caching Multiple Domain with Varnish\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/aws-2\\\/#listItem\",\"name\":\"AWS\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/abhishek-tomar\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/abhishek-tomar\\\/\",\"name\":\"abhishek.tomar\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6606885f7c0669268a111875f6c0ef05104c83e6c62be85ed3258b6a3c4ca1b8?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"abhishek.tomar\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/\",\"name\":\"Caching Multiple Domain with Varnish | TO THE NEW Blog\",\"description\":\"Varnish is an in-memory web accelerator server which helps Apache\\\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/caching-multiple-domain-with-varnish\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/abhishek-tomar\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/abhishek-tomar\\\/#author\"},\"datePublished\":\"2014-03-24T14:25:24+05:30\",\"dateModified\":\"2014-03-24T14:27:25+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Caching Multiple Domain with Varnish | TO THE NEW Blog","description":"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it","canonical_url":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#article","name":"Caching Multiple Domain with Varnish | TO THE NEW Blog","headline":"Caching Multiple Domain with Varnish","author":{"@id":"https:\/\/2thenew.online\/blog\/author\/abhishek-tomar\/#author"},"publisher":{"@id":"https:\/\/2thenew.online\/blog\/#organization"},"datePublished":"2014-03-24T14:25:24+05:30","dateModified":"2014-03-24T14:27:25+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#webpage"},"articleSection":"AWS, Cache, multiple domain, varnish"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.online\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/aws-2\/#listItem","name":"AWS"}},{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/aws-2\/#listItem","position":2,"name":"AWS","item":"https:\/\/2thenew.online\/blog\/category\/aws-2\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#listItem","name":"Caching Multiple Domain with Varnish"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#listItem","position":3,"name":"Caching Multiple Domain with Varnish","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.online\/blog\/category\/aws-2\/#listItem","name":"AWS"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.online\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.online\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.online\/blog\/author\/abhishek-tomar\/#author","url":"https:\/\/2thenew.online\/blog\/author\/abhishek-tomar\/","name":"abhishek.tomar","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/6606885f7c0669268a111875f6c0ef05104c83e6c62be85ed3258b6a3c4ca1b8?s=96&d=mm&r=g","width":96,"height":96,"caption":"abhishek.tomar"}},{"@type":"WebPage","@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#webpage","url":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/","name":"Caching Multiple Domain with Varnish | TO THE NEW Blog","description":"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.online\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.online\/blog\/author\/abhishek-tomar\/#author"},"creator":{"@id":"https:\/\/2thenew.online\/blog\/author\/abhishek-tomar\/#author"},"datePublished":"2014-03-24T14:25:24+05:30","dateModified":"2014-03-24T14:27:25+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.online\/blog\/#website","url":"https:\/\/2thenew.online\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.online\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Caching Multiple Domain with Varnish | TO THE NEW Blog","og:description":"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it","og:url":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/","og:image":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Caching Multiple Domain with Varnish | TO THE NEW Blog","twitter:description":"Varnish is an in-memory web accelerator server which helps Apache\/Nginx server to run 10-300 times faster without spending anything on procuring hardware. Besides this It can also be used as a reverse proxy server. In our projects we are using Varnish to cache the static content and in some cases we are also using it","twitter:image":"https:\/\/2thenew.online\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"12361","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 01:09:41","updated":"2024-02-29 08:56:30","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.online\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.online\/blog\/category\/aws-2\/\" title=\"AWS\">AWS<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tCaching Multiple Domain with Varnish\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.online\/blog"},{"label":"AWS","link":"https:\/\/2thenew.online\/blog\/category\/aws-2\/"},{"label":"Caching Multiple Domain with Varnish","link":"https:\/\/2thenew.online\/blog\/caching-multiple-domain-with-varnish\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/12361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/comments?post=12361"}],"version-history":[{"count":0,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/posts\/12361\/revisions"}],"wp:attachment":[{"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/media?parent=12361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/categories?post=12361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.online\/blog\/wp-json\/wp\/v2\/tags?post=12361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}