Saltstack Official Apache Formula

преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 10 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 10 години
преди 10 години
преди 10 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. <VirtualHost {{ vals.interface }}:{{ vals.port }}>
  33. ServerName {{ vals.ServerName }}
  34. {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
  35. {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
  36. {% if site.get('DirectoryIndex') %}DirectoryIndex {{ vals.DirectoryIndex }}{% endif %}
  37. {% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
  38. {% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
  39. {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %}
  40. {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
  41. {% if site.get('DocumentRoot') != False %}DocumentRoot {{ vals.DocumentRoot }}{% endif %}
  42. {% if site.get('VirtualDocumentRoot') %}VirtualDocumentRoot {{ vals.VirtualDocumentRoot }}{% endif %}
  43. {% if site.get('SSLCertificateFile') %}
  44. SSLEngine on
  45. SSLCertificateFile {{ site.SSLCertificateFile }}
  46. {% if site.get('SSLCertificateKeyFile') %}
  47. SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}
  48. {% endif %}
  49. {% if site.get('SSLCertificateChainFile') %}
  50. SSLCertificateChainFile {{ site.SSLCertificateChainFile}}
  51. {% endif %}
  52. {% endif %}
  53. {% for loc, path in site.get('Alias', {}).items() %}
  54. Alias {{ loc }} {{ path }}
  55. {% endfor %}
  56. {% for path, dir in site.get('Directory', {}).items() %}
  57. {% set dvals = {
  58. 'Options': dir.get('Options', vals.Directory.Options),
  59. 'Order': dir.get('Order', vals.Directory.Order),
  60. 'Allow': dir.get('Allow', vals.Directory.Allow),
  61. 'Require': dir.get('Require', vals.Directory.Require),
  62. 'AllowOverride': dir.get('AllowOverride', vals.Directory.AllowOverride),
  63. 'Dav': dir.get('Dav', False),
  64. } %}
  65. {% if path == 'default' %}{% set path = vals.Directory_default %}{% endif %}
  66. <Directory "{{ path }}">
  67. {% if dvals.get('Options') != False %}Options {{ dvals.Options }}{% endif %}
  68. {% if apache.use_require %}
  69. {% if dvals.get('Require') != False %}Require {{dvals.Require}}{% endif %}
  70. {% else %}
  71. {% if dvals.get('Order') != False %}Order {{ dvals.Order }}{% endif %}
  72. {% if dvals.get('Allow') != False %}Allow {{ dvals.Allow }}{% endif %}
  73. {% endif %}
  74. {% if dvals.get('AllowOverride') != False %}AllowOverride {{ dvals.AllowOverride }}{% endif %}
  75. {% if dvals.get('Dav') != False %}Dav On{% endif %}
  76. {% if dir.get('Formula_Append') %}
  77. {{ dir.Formula_Append|indent(8) }}
  78. {% endif %}
  79. </Directory>
  80. {% endfor %}
  81. {% for path, loc in site.get('Location', {}).items() %}
  82. {% set lvals = {
  83. 'Order': loc.get('Order', vals.Location.Order),
  84. 'Allow': loc.get('Allow', vals.Location.Allow),
  85. 'Require': loc.get('Require', vals.Location.Require),
  86. 'Dav': loc.get('Dav', False),
  87. } %}
  88. <Location "{{ path }}">
  89. {% if apache.use_require %}
  90. {% if lvals.get('Require') != False %}Require {{lvals.Require}}{% endif %}
  91. {% else %}
  92. {% if lvals.get('Order') != False %}Order {{ lvals.Order }}{% endif %}
  93. {% if lvals.get('Allow') != False %}Allow {{ lvals.Allow }}{% endif %}
  94. {% endif %}
  95. {% if lvals.get('Dav') != False %}Dav On{% endif %}
  96. {% if loc.get('Formula_Append') %}
  97. {{ loc.Formula_Append|indent(8) }}
  98. {% endif %}
  99. </Location>
  100. {% endfor %}
  101. {% if site.get('Formula_Append') %}
  102. {{ site.Formula_Append|indent(4) }}
  103. {% endif %}
  104. </VirtualHost>