From 44131dc58380fd2adddc50c13b3c996e740cd1c6 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Mon, 14 Mar 2016 11:27:44 +0100
Subject: [PATCH] Allow access to Varnish control panel from Drupal sites

---
 templates/haproxy_cfg | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/templates/haproxy_cfg b/templates/haproxy_cfg
index fbe3247..22f5bb4 100644
--- a/templates/haproxy_cfg
+++ b/templates/haproxy_cfg
@@ -99,7 +99,11 @@ backend backend_{{host}}
 {% if varnish_host|default(false) %}
 
 backend backend_varnish
-  server varnish {{ varnish_host }}:6081 maxconn 32
+{% if varnish_host == inventory_host %}
+  server varnish 127.0.0.1:6081 maxconn 32
+{% else %}
+  server varnish {{ hostvars[varnish_host]['static_ipv4']|default(hostvars[varnish_host]['ansible_default_ipv4']['address']) }}:6081 maxconn 32
+{% endif %}
 {% endif %}
 
 backend backend_redirect_ssl
-- 
GitLab