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.

141 lines
5.8KB

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