Saltstack Official Apache Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

standard.tmpl 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {# Define default values here so the template below can just focus on layout #}
  2. {%- from "apache/map.jinja" import apache with context -%}
  3. {%- set sitename = site.get('ServerName', id) -%}
  4. {%- set vals = {
  5. 'interfaces': site.get('interface', '*').split(),
  6. 'port': site.get('port', '80'),
  7. 'ServerName': sitename,
  8. 'ServerAlias': site.get('ServerAlias', 'www.{0}'.format(sitename)),
  9. 'ServerAdmin': site.get('ServerAdmin', 'webmaster@{0}'.format(sitename)),
  10. 'DirectoryIndex': site.get('DirectoryIndex'),
  11. 'UseCanonicalName': site.get('UseCanonicalName'),
  12. 'AllowEncodedSlashes': site.get('AllowEncodedSlashes', 'Off'),
  13. 'LogLevel': site.get('LogLevel', 'warn'),
  14. 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
  15. 'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
  16. 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
  17. 'DocumentRoot': site.get('DocumentRoot', '{0}/{1}'.format(map.wwwdir, sitename)),
  18. 'VirtualDocumentRoot': site.get('VirtualDocumentRoot'),
  19. 'Timeout': site.get('Timeout'),
  20. 'LimitRequestFields': site.get('LimitRequestFields'),
  21. 'Directory_default': '{0}/{1}'.format(map.wwwdir, sitename),
  22. 'Directory': {
  23. 'Options': '-Indexes +FollowSymLinks',
  24. 'Order': 'allow,deny',
  25. 'Allow': 'from all',
  26. 'Require': 'all granted',
  27. 'AllowOverride': 'None',
  28. },
  29. 'Location': {
  30. 'Order': 'allow,deny',
  31. 'Allow': 'from all',
  32. 'Require': 'all granted',
  33. },
  34. } -%}
  35. <VirtualHost {% for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
  36. ServerName {{ vals.ServerName }}
  37. {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
  38. {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
  39. {% if site.get('DirectoryIndex') -%}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %}
  40. {% if site.get('UseCanonicalName') -%}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
  41. {% if site.get('AllowEncodedSlashes') != False -%}AllowEncodedSlashes {{ vals.AllowEncodedSlashes }}{% endif %}
  42. {% if site.get('LogLevel') != False -%}LogLevel {{ vals.LogLevel }}{% endif %}
  43. {% if site.get('ErrorLog') != False -%}ErrorLog {{ vals.ErrorLog }}{% endif %}
  44. {% if site.get('CustomLog') != False -%}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
  45. {% if site.get('DocumentRoot') != False -%}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
  46. {% if site.get('VirtualDocumentRoot') -%}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
  47. {% if site.get('Timeout') != False and site.get('Timeout') != None %}Timeout {{ vals.Timeout }}{% endif %}
  48. {% if site.get('LimitRequestFields') %}LimitRequestFields {{ vals.LimitRequestFields }}{% endif %}
  49. {%- if site.get('SSLCertificateFile') %}
  50. SSLEngine on
  51. SSLCertificateFile {{ site.SSLCertificateFile }}
  52. {%- if site.get('SSLCertificateKeyFile') %}
  53. SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}
  54. {%- endif %}
  55. {%- if site.get('SSLCertificateChainFile') %}
  56. SSLCertificateChainFile {{ site.SSLCertificateChainFile}}
  57. {%- endif %}
  58. {%- endif %}
  59. {%- for loc, path in site.get('Alias', {}).items() %}
  60. Alias {{ loc }} {{ path }}
  61. {%- endfor %}
  62. {%- for path, dir in site.get('Directory', {}).items() -%}
  63. {%- set dvals = {
  64. 'Options': dir.get('Options', vals.Directory.Options),
  65. 'Order': dir.get('Order', vals.Directory.Order),
  66. 'Allow': dir.get('Allow', vals.Directory.Allow),
  67. 'Require': dir.get('Require', vals.Directory.Require),
  68. 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
  69. 'Dav': dir.get('Dav', False),
  70. } %}
  71. {%- if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
  72. <Directory "{{ path }}">
  73. {% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
  74. {% if apache.use_require %}
  75. {% if dvals.get('Require') != False %}Require {{dvals.Require}}{% endif %}
  76. {% else %}
  77. {% if dvals.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
  78. {% if dvals.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
  79. {% endif %}
  80. {% if dvals.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
  81. {% if dvals.get('Dav') != False %}Dav On{% endif %}
  82. {% if dir.get('Formula_Append') %}
  83. {{ dir.Formula_Append|indent(8) }}
  84. {% endif %}
  85. </Directory>
  86. {%- endfor %}
  87. {%- for path, loc in site.get('Location', {}).items() %}
  88. {%- set lvals = {
  89. 'Order': loc.get('Order', vals.Location.Order),
  90. 'Allow': loc.get('Allow', vals.Location.Allow),
  91. 'Require': loc.get('Require', vals.Location.Require),
  92. 'Dav': loc.get('Dav', False),
  93. } %}
  94. <Location "{{ path }}">
  95. {% if apache.use_require %}
  96. {%- if lvals.get('Require') != False %}Require {{lvals.Require}}{% endif %}
  97. {% else %}
  98. {%- if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
  99. {%- if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
  100. {% endif %}
  101. {%- if lvals.get('Dav') != False %}Dav On{% endif %}
  102. {%- if loc.get('Formula_Append') %}
  103. {{ loc.Formula_Append|indent(8) }}
  104. {% endif %}
  105. </Location>
  106. {% endfor %}
  107. {%- if site.get('Formula_Append') %}
  108. {{ site.Formula_Append|indent(4) }}
  109. {% endif %}
  110. </VirtualHost>