Merge pull request #37 from daschatten/master
Add templates 'redirect.tmpl' and 'proxy.tmpl'.
This commit is contained in:
commit
56629310ca
48
apache/vhosts/proxy.tmpl
Normal file
48
apache/vhosts/proxy.tmpl
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
{# Define default values here so the template below can just focus on layout #}
|
||||||
|
{% from "apache/map.jinja" import apache with context %}
|
||||||
|
{% set sitename = site.get('ServerName', id) %}
|
||||||
|
|
||||||
|
{% set vals = {
|
||||||
|
'interface': site.get('interface', '*'),
|
||||||
|
'port': site.get('port', '80'),
|
||||||
|
|
||||||
|
'ServerName': sitename,
|
||||||
|
'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)),
|
||||||
|
|
||||||
|
'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)),
|
||||||
|
|
||||||
|
'UseCanonicalName': site.get('UseCanonicalName'),
|
||||||
|
|
||||||
|
'LogLevel': site.get('LogLevel', 'warn'),
|
||||||
|
'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
|
||||||
|
'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
|
||||||
|
'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))),
|
||||||
|
|
||||||
|
} %}
|
||||||
|
|
||||||
|
<VirtualHost {{ vals.interface }}:{{ vals.port }}>
|
||||||
|
ServerName {{ vals.ServerName }}
|
||||||
|
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
|
||||||
|
|
||||||
|
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
||||||
|
|
||||||
|
{% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
|
||||||
|
|
||||||
|
{% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
|
||||||
|
{% 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 }}
|
||||||
|
|
||||||
|
{% if site.get('Formula_Append') %}
|
||||||
|
{{ site.Formula_Append|indent(4) }}
|
||||||
|
{% endif %}
|
||||||
|
</VirtualHost>
|
43
apache/vhosts/redirect.tmpl
Normal file
43
apache/vhosts/redirect.tmpl
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{# Define default values here so the template below can just focus on layout #}
|
||||||
|
{% from "apache/map.jinja" import apache with context %}
|
||||||
|
{% set sitename = site.get('ServerName', id) %}
|
||||||
|
|
||||||
|
{% set vals = {
|
||||||
|
'interface': site.get('interface', '*'),
|
||||||
|
'port': site.get('port', '80'),
|
||||||
|
|
||||||
|
'ServerName': sitename,
|
||||||
|
'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)),
|
||||||
|
|
||||||
|
'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)),
|
||||||
|
|
||||||
|
'UseCanonicalName': site.get('UseCanonicalName'),
|
||||||
|
|
||||||
|
'LogLevel': site.get('LogLevel', 'warn'),
|
||||||
|
'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
|
||||||
|
'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
|
||||||
|
'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
|
||||||
|
|
||||||
|
'RedirectSource': site.get('RedirectSource', '/'),
|
||||||
|
'RedirectTarget': site.get('RedirectTarget', 'https://{0}'.format(sitename)),
|
||||||
|
|
||||||
|
} %}
|
||||||
|
|
||||||
|
<VirtualHost {{ vals.interface }}:{{ vals.port }}>
|
||||||
|
ServerName {{ vals.ServerName }}
|
||||||
|
{% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
|
||||||
|
|
||||||
|
{% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
|
||||||
|
|
||||||
|
{% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
|
||||||
|
|
||||||
|
{% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
|
||||||
|
{% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %}
|
||||||
|
{% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
|
||||||
|
|
||||||
|
Redirect {{ vals.RedirectSource }} {{ vals.RedirectTarget }}
|
||||||
|
|
||||||
|
{% if site.get('Formula_Append') %}
|
||||||
|
{{ site.Formula_Append|indent(4) }}
|
||||||
|
{% endif %}
|
||||||
|
</VirtualHost>
|
@ -18,7 +18,7 @@ apache:
|
|||||||
template_file: salt://apache/vhosts/minimal.tmpl
|
template_file: salt://apache/vhosts/minimal.tmpl
|
||||||
|
|
||||||
example.com: # must be unique; used as an ID declaration in Salt.
|
example.com: # must be unique; used as an ID declaration in Salt.
|
||||||
template_file: salt://apache/vhosts/standard.tmpl
|
template_file: salt://apache/vhosts/standard.tmpl # or redirect.tmpl or proxy.tmpl
|
||||||
|
|
||||||
####################### DEFAULT VALUES BELOW ############################
|
####################### DEFAULT VALUES BELOW ############################
|
||||||
# NOTE: the values below are simply default settings that *can* be
|
# NOTE: the values below are simply default settings that *can* be
|
||||||
@ -57,6 +57,17 @@ apache:
|
|||||||
Additional config as a
|
Additional config as a
|
||||||
multi-line string here
|
multi-line string here
|
||||||
|
|
||||||
|
# if template is 'redirect.tmpl'
|
||||||
|
# RedirectSource: '/'
|
||||||
|
# RedirectTarget: 'http://www.example.net'
|
||||||
|
|
||||||
|
# if template is 'proxy.tmpl'
|
||||||
|
# ProxyPreserveHost: 'On'
|
||||||
|
# ProxyPassSource: '/'
|
||||||
|
# ProxyPassTarget: 'http://www.example.net'
|
||||||
|
# ProxyPassReverseSource: '/'
|
||||||
|
# ProxyPassReverseTarget: 'http://www.example.net'
|
||||||
|
|
||||||
Formula_Append: |
|
Formula_Append: |
|
||||||
Additional config as a
|
Additional config as a
|
||||||
multi-line string here
|
multi-line string here
|
||||||
|
Loading…
Reference in New Issue
Block a user