Saltstack Official Nginx 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.

80 lines
2.3KB

  1. {% macro sls_block(dict) %}
  2. {% for key, value in dict.items() %}
  3. - {{ key }}: {{ value|json() }}
  4. {% endfor %}
  5. {% endmacro %}
  6. {% set nginx = salt['pillar.get']('nginx:ng', {
  7. 'lookup': salt['grains.filter_by']({
  8. 'Debian': {
  9. 'package': 'nginx',
  10. 'service': 'nginx',
  11. 'webuser': 'www-data',
  12. 'conf_file': '/etc/nginx/nginx.conf',
  13. 'vhost_available': '/etc/nginx/sites-available',
  14. 'vhost_enabled': '/etc/nginx/sites-enabled',
  15. 'vhost_use_symlink': True,
  16. },
  17. 'RedHat': {
  18. 'package': 'nginx',
  19. 'service': 'nginx',
  20. 'webuser': 'httpd',
  21. 'conf_file': '/etc/nginx/nginx.conf',
  22. 'vhost_available': '/etc/nginx/conf.d',
  23. 'vhost_enabled': '/etc/nginx/conf.d',
  24. 'vhost_use_symlink': False,
  25. },
  26. }, default='Debian' ),
  27. 'from_source': False,
  28. 'package': {
  29. 'opts': {},
  30. },
  31. 'service': {
  32. 'enable': True,
  33. 'opts': {},
  34. },
  35. 'server': {
  36. 'opts': {},
  37. 'config': {
  38. 'worker_processes': 4,
  39. 'pid': '/run/nginx.pid',
  40. 'events': {
  41. 'worker_connections': 768,
  42. },
  43. 'http': {
  44. 'sendfile': 'on',
  45. 'tcp_nopush': 'on',
  46. 'tcp_nodelay': 'on',
  47. 'keepalive_timeout': '65',
  48. 'types_hash_max_size': '2048',
  49. 'default_type': 'application/octet-stream',
  50. 'access_log': '/var/log/nginx/access.log',
  51. 'error_log': '/var/log/nginx/error.log',
  52. 'gzip': 'off',
  53. 'gzip_disable': '"msie6"',
  54. 'include': [
  55. '/etc/nginx/mime.types',
  56. '/etc/nginx/conf.d/*.conf',
  57. '/etc/nginx/sites-enabled/*',
  58. ],
  59. },
  60. },
  61. },
  62. 'vhosts': {
  63. 'disabled_postfix': '.disabled',
  64. 'symlink_opts': {},
  65. 'rename_opts': {},
  66. 'managed_opts': {},
  67. 'dir_opts': {
  68. 'makedirs': True,
  69. },
  70. 'managed': {},
  71. },
  72. }, merge=True) %}
  73. {% if 'user' not in nginx.server.config %}
  74. {% do nginx.server.config.update({
  75. 'user': nginx.lookup.webuser,
  76. })%}
  77. {% endif %}