From fce8d72c12242f29516efc082835433fe29147b2 Mon Sep 17 00:00:00 2001 From: "sebastien.fleury" Date: Wed, 11 Mar 2015 18:28:11 +0100 Subject: [PATCH] Issue#41 configure multi proxypass configuration in vhost --- apache/vhosts/proxy.tmpl | 22 +++++++++++++--------- pillar.example | 10 ++++++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/apache/vhosts/proxy.tmpl b/apache/vhosts/proxy.tmpl index 595d2db..356b115 100644 --- a/apache/vhosts/proxy.tmpl +++ b/apache/vhosts/proxy.tmpl @@ -19,11 +19,7 @@ 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)), 'ProxyPreserveHost': site.get('ProxyPreserveHost', 'On'), - 'ProxyPassSource': site.get('ProxyPassSource', '/'), - 'ProxyPassTarget': site.get('ProxyPassTarget', 'https://{0}'.format(sitename)), - 'ProxyPassReverseSource': site.get('ProxyPassReverseSource', site.get('ProxyPassSource', '/')), - 'ProxyPassReverseTarget': site.get('ProxyPassReverseTarget', site.get('ProxyPassTarget', 'https://{0}'.format(sitename))), - + 'ProxyRoute': site.get('ProxyRoute', {}), } %} @@ -38,10 +34,18 @@ {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %} {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %} - ProxyPreserveHost {{ vals.ProxyPreserveHost }} - ProxyPass {{ vals.ProxyPassSource }} {{ vals.ProxyPassTarget }} - ProxyPassReverse {{ vals.ProxyPassReverseSource }} {{ vals.ProxyPassReverseTarget }} - + ProxyPreserveHost {{ vals.ProxyPreserveHost }} + {% for proxy, proxyargs in reverse(vals.ProxyRoute.items()) %} + {% set proxyvals = { + 'ProxyPassSource': proxyargs.get('ProxyPassSource', '/'), + 'ProxyPassTarget': proxyargs.get('ProxyPassTarget', 'https://{0}'.format(sitename)), + 'ProxyPassReverseSource': proxyargs.get('ProxyPassReverseSource', '/'), + 'ProxyPassReverseTarget': proxyargs.get('ProxyPassReverseTarget', site.get('ProxyPassTarget', 'https://{0}'.format(sitename))), + } %} + ######### {{proxy}} ######### + ProxyPass {{ proxyvals.ProxyPassSource }} {{ proxyvals.ProxyPassTarget }} + ProxyPassReverse {{ proxyvals.ProxyPassReverseSource }} {{ proxyvals.ProxyPassReverseTarget }} + {% endfor %} {% if site.get('Formula_Append') %} {{ site.Formula_Append|indent(4) }} {% endif %} diff --git a/pillar.example b/pillar.example index 65deac6..87d104d 100644 --- a/pillar.example +++ b/pillar.example @@ -63,10 +63,12 @@ apache: # if template is 'proxy.tmpl' # ProxyPreserveHost: 'On' - # ProxyPassSource: '/' - # ProxyPassTarget: 'http://www.example.net' - # ProxyPassReverseSource: '/' - # ProxyPassReverseTarget: 'http://www.example.net' + # ProxyRoute: + # my sample route: + # ProxyPassSource: '/' + # ProxyPassTarget: 'http://www.example.net' + # ProxyPassReverseSource: '/' + # ProxyPassReverseTarget: 'http://www.example.net' Formula_Append: | Additional config as a