Saltstack Official Apache Formula
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

64 lines
2.8KB

  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. 'UseCanonicalName': site.get('UseCanonicalName'),
  11. 'LogLevel': site.get('LogLevel', 'warn'),
  12. 'ErrorLog': site.get('ErrorLog', '{0}/{1}-error.log'.format(map.logdir, sitename)),
  13. 'LogFormat': site.get('LogFormat', '"%h %l %u %t \\\"%r\\\" %>s %O"'),
  14. 'CustomLog': site.get('CustomLog', '{0}/{1}-access.log'.format(map.logdir, sitename)),
  15. 'ProxyPreserveHost': site.get('ProxyPreserveHost', 'On'),
  16. 'ProxyRoute': site.get('ProxyRoute', {}),
  17. } %}
  18. <VirtualHost {%- for intf in vals.interfaces %} {{intf}}:{{ vals.port }}{% endfor -%}>
  19. ServerName {{ vals.ServerName }}
  20. {% if site.get('ServerAlias') != False %}ServerAlias {{ vals.ServerAlias }}{% endif %}
  21. {% if site.get('ServerAdmin') != False %}ServerAdmin {{ vals.ServerAdmin }}{% endif %}
  22. {% if site.get('UseCanonicalName') %}UseCanonicalName {{ vals.UseCanonicalName }}{% endif %}
  23. {% if site.get('LogLevel') != False %}LogLevel {{ vals.LogLevel }}{% endif %}
  24. {% if site.get('ErrorLog') != False %}ErrorLog {{ vals.ErrorLog }}{% endif %}
  25. {% if site.get('CustomLog') != False %}CustomLog {{ vals.CustomLog }} {{ vals.LogFormat }}{% endif %}
  26. {% if site.get('SSLCertificateFile') %}
  27. SSLEngine on
  28. SSLCertificateFile {{ site.SSLCertificateFile }}
  29. {% if site.get('SSLCertificateKeyFile') %}
  30. SSLCertificateKeyFile {{ site.SSLCertificateKeyFile }}
  31. {% endif %}
  32. {% if site.get('SSLCertificateChainFile') %}
  33. SSLCertificateChainFile {{ site.SSLCertificateChainFile}}
  34. {% endif %}
  35. {% endif %}
  36. ProxyPreserveHost {{ vals.ProxyPreserveHost }}
  37. {% for proxy, proxyargs in vals.ProxyRoute|dictsort|reverse %}
  38. {% set proxyvals = {
  39. 'ProxyPassSource': proxyargs.get('ProxyPassSource', '/'),
  40. 'ProxyPassTarget': proxyargs.get('ProxyPassTarget', 'https://{0}'.format(sitename)),
  41. 'ProxyPassReverseSource': proxyargs.get('ProxyPassReverseSource', '/'),
  42. 'ProxyPassReverseTarget': proxyargs.get('ProxyPassReverseTarget', site.get('ProxyPassTarget', 'https://{0}'.format(sitename))),
  43. } %}
  44. ######### {{proxy}} #########
  45. ProxyPass {{ proxyvals.ProxyPassSource }} {{ proxyvals.ProxyPassTarget }}
  46. ProxyPassReverse {{ proxyvals.ProxyPassReverseSource }} {{ proxyvals.ProxyPassReverseTarget }}
  47. {% endfor %}
  48. {% if site.get('Formula_Append') %}
  49. {{ site.Formula_Append|indent(4) }}
  50. {% endif %}
  51. </VirtualHost>