Saltstack Official Apache Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

129 lines
5.0KB

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