meesteridle

varnishd 4.0 -- default.vcl vhost regex

Jun 29th, 2015
5,116
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 1.69 KB | None | 0 0
  1. vcl 4.0;
  2.  
  3. # I used 172.31.27.119 to avoid a 127.0.0.1:80 conflict
  4. # between varnishd and the backend (nginx in my case).
  5. # I defined only one backend since all my nginx vhosts
  6. # are running on 172.31.27.119:8080.
  7. # NOTE: eth0 is using a static IP configuration.
  8. backend default {
  9.     .host = "172.31.27.119";
  10.     .port = "8080";
  11. }
  12.  
  13. sub vcl_recv {
  14.     # matches www.example.net AND example.net
  15.     if (req.http.host == "(www.)example.net") {
  16.         set req.backend_hint = default;
  17.     }
  18.     # matches www.example.org AND example.org
  19.     if (req.http.host == "(www.)example.org") {
  20.         set req.backend_hint = default;
  21.     }
  22.     # matches www.example.com AND example.com
  23.     if (req.http.host == "(www.)example.com") {
  24.         set req.backend_hint = default;
  25.     }
  26.     # matches www.example.org AND example.org OR
  27.     # matches www.example.com AND example.com OR
  28.     # matches www.example.net AND example.net
  29.     if (req.http.host == "(www.)example.\borg|com|net\b") {
  30.         set req.backend_hint = default;
  31.     }
  32.     # matches www.idlemind.net AND idlemind.net OR
  33.     # matches www.idl3mind.net AND idl3mind.net
  34.     if (req.http.host == "(www.)idl[e3]mind.net" ) {
  35.         set req.backend_hint = default;
  36.     }
  37.     # matches www.helpwithdragon.com AND helpwithdragon.com OR
  38.     # matches www.help-with-dragon.com AND help-with-dragon.com
  39.     if (req.http.host == "(www.)help[\-]with[\-]dragon.com" ) {
  40.         set req.backend_hint = default;
  41.     }
  42.     # matches www.badmojobrew.com AND badmojobrew.com OR
  43.     # matches www.badmojobrewery.com AND badmojobrewery.com OR
  44.     # matches www.badmojobrewing.com AND badmojobrewing.com OR
  45.     # matches www.badmojobrewingco.com AND badmojobrewingco.com OR
  46.     if (req.http.host == "(www.)badmojobrew\bery|ing|ingco\b.com" ) {
  47.         set req.backend_hint = default;
  48.     }
  49. }
Advertisement
Comments
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment