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.

README.adoc 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. = apache
  2. https://travis-ci.com/saltstack-formulas/apache-formula[image:https://travis-ci.com/saltstack-formulas/apache-formula.svg?branch=master[Travis CI Build Status]]
  3. https://github.com/semantic-release/semantic-release[image:https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg[Semantic Release]]
  4. Formulas to set up and configure the Apache HTTP server on GNU/Linux,
  5. FreeBSD, and Windows OS.
  6. == General notes
  7. See the full
  8. https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html[SaltStack
  9. Formulas installation and usage instructions].
  10. If you are interested in writing or contributing to formulas, please pay
  11. attention to the
  12. https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas[Writing
  13. Formula Section].
  14. If you want to use this formula, please pay attention to the `+FORMULA+`
  15. file and/or `+git tag+`, which contains the currently released version.
  16. This formula is versioned according to http://semver.org/[Semantic
  17. Versioning].
  18. See
  19. https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning[Formula
  20. Versioning Section] for more details.
  21. == Contributing to this repo
  22. *Commit message formatting is significant!!*
  23. Please see
  24. xref:main::CONTRIBUTING.adoc[How
  25. to contribute] for more details.
  26. == Available states
  27. === `+apache+`
  28. Installs the Apache package and starts the service.
  29. === `+apache.config+`
  30. Metastate to apply all apache configuration
  31. === `+apache.config.file+`
  32. Configures apache based on os_family
  33. === `+apache.config.flags+`
  34. Configures apache flags on SuSE
  35. === `+apache.config.certificates+`
  36. Deploy SSL certificates from pillars
  37. === `+apache.config.modules+`
  38. Metastate to Enable and disable Apache modules.
  39. === `+apache.config.modules.mod_mpm+`
  40. Configures the apache mpm modules on Debian `+mpm_prefork+`,
  41. `+mpm_worker+` or `+mpm_event+` (Debian Only)
  42. === `+apache.config.modules.mod_rewrite+`
  43. Enabled the Apache module mod_rewrite (Debian and FreeBSD only)
  44. === `+apache.config.modules.mod_proxy+`
  45. Enables the Apache module mod_proxy. (Debian and FreeBSD only)
  46. === `+apache.config.modules.mod_proxy_http+`
  47. Enables the Apache module mod_proxy_http and requires the Apache module
  48. mod_proxy to be enabled. (Debian Only)
  49. === `+apache.config.modules.mod_proxy_fcgi+`
  50. Enables the Apache module mod_proxy_fcgi and requires the Apache module
  51. mod_proxy to be enabled. (Debian Only)
  52. === `+apache.config.modules.mod_wsgi+`
  53. Installs the mod_wsgi package and enables the Apache module.
  54. === `+apache.config.modules.mod_actions+`
  55. Enables the Apache module mod_actions. (Debian Only)
  56. === `+apache.config.modules.mod_headers+`
  57. Enables the Apache module mod_headers. (Debian Only)
  58. === `+apache.config.modules.mod_pagespeed+`
  59. Installs and Enables the mod_pagespeed module. (Debian and RedHat Only)
  60. === `+apache.config.modules.mod_perl2+`
  61. Installs and enables the mod_perl2 module (Debian and FreeBSD only)
  62. === `+apache.config.modules.mod_geoip+`
  63. Installs and enables the mod_geoIP (RedHat only)
  64. === `+apache.config.modules.mod_php5+`
  65. Installs and enables the mod_php5 module
  66. === `+apache.config.modules.mod_cgi+`
  67. Enables mod_cgi. (FreeBSD only)
  68. === `+apache.config.modules.mod_fcgid+`
  69. Installs and enables the mod_fcgid module (Debian only)
  70. === `+apache.config.modules.mod_fastcgi+`
  71. Installs and enables the mod_fastcgi module
  72. === `+apache.config.modules.mod_dav_svn+`
  73. Installs and enables the mod_dav_svn module (Debian only)
  74. === `+apache.config.modules.mod_security+`
  75. Installs an enables the http://modsecurity.org/[Apache mod_security2
  76. WAF] using data from Pillar. (Debian and RedHat Only)
  77. Allows you to install the basic Core Rules (CRS) and some basic
  78. configuration for mod_security2
  79. === `+apache.config.modules.mod_security.rules+`
  80. This state can create symlinks based on basic Core Rules package.
  81. (Debian only) Or it can distribute a mod_security rule file and place it
  82. /etc/modsecurity/
  83. === `+apache.config.modules.mod_socache_shmcb+`
  84. Enables mod_socache_shmcb. (FreeBSD only)
  85. === `+apache.config.modules.mod_ssl+`
  86. Installs and enables the mod_ssl module (Debian, RedHat and FreeBSD
  87. only)
  88. === `+apache.config.modules.mod_suexec+`
  89. Enables mod_suexec. (FreeBSD only)
  90. === `+apache.config.modules.mod_vhost_alias+`
  91. Enables the Apache module vhost_alias (Debian Only)
  92. === `+apache.config.modules.mod_remoteip+`
  93. Enables and configures the Apache module mod_remoteip using data from
  94. Pillar. (Debian Only)
  95. === `+apache.config.modules.mod_xsendfile+`
  96. Installs and enables mod_xsendfile module. (Debian Only)
  97. === `+apache.config.own_default_vhost+`
  98. Replace default vhost with own version. By default, it's 503 code.
  99. (Debian Only)
  100. === `+apache.config.no_default_vhost+`
  101. Remove the default vhost. (Debian Only)
  102. === `+apache.config.vhosts.standard+`
  103. Configures Apache name-based virtual hosts and creates virtual host
  104. directories using data from Pillar.
  105. Example Pillar:
  106. [source,yaml]
  107. ----
  108. apache:
  109. sites:
  110. example.com: # must be unique; used as an ID declaration in Salt; also passed to the template context as {{ id }}
  111. template_file: salt://apache/vhosts/standard.tmpl
  112. ----
  113. When using the provided templates, one can use a space separated list of
  114. interfaces to bind to. For example, to bind both IPv4 and IPv6:
  115. [source,yaml]
  116. ----
  117. apache:
  118. sites:
  119. example.com:
  120. interface: '1.2.3.4 [2001:abc:def:100::3]'
  121. ----
  122. === `+apache.config.manage_security+`
  123. Configures Apache's security.conf options by reassinging them using data
  124. from Pillar.
  125. === `+apache.config.modules.mod_status+`
  126. Configures Apache's server_status handler for localhost
  127. === `+apache.config.debian_full+`
  128. Installs and configures Apache on Debian and Ubuntu systems.
  129. === `+apache.config.clean+`
  130. Metastate to cleanup all apache configuration.
  131. === `+apache.clean+`
  132. Stops the Apache service and uninstalls the package.
  133. These states are ordered using the `+order+` declaration. Different
  134. stages are divided into the following number ranges:
  135. [arabic]
  136. . apache will use 1-500 for ordering
  137. . apache will reserve 1 -100 as unused
  138. . apache will reserve 101-150 for pre pkg install
  139. . apache will reserve 151-200 for pkg install
  140. . apache will reserve 201-250 for pkg configure
  141. . apache will reserve 251-300 for downloads, git stuff, load data
  142. . apache will reserve 301-400 for unknown purposes
  143. . apache will reserve 401-450 for service restart-reloads
  144. . apache WILL reserve 451-460 for service.running
  145. . apache will reserve 461-500 for cmd requiring operational services
  146. Example Pillar:
  147. [source,yaml]
  148. ----
  149. apache:
  150. register-site:
  151. # any name as an array index, and you can duplicate this section
  152. {{UNIQUE}}:
  153. name: 'my name'
  154. path: 'salt://path/to/sites-available/conf/file'
  155. state: 'enabled'
  156. sites:
  157. # Force SSL: Redirect from 80 to 443
  158. example.com:
  159. port: 80
  160. template_file: salt://apache/vhosts/redirect.tmpl
  161. RedirectSource: 'permanent /'
  162. # Trailing slash is important
  163. RedirectTarget: 'https://example.com/'
  164. example.com_ssl:
  165. port: 443
  166. ServerName: example.com
  167. SSLCertificateFile: /path/to/ssl.crt
  168. SSLCertificateKeyFile: /path/to/ssl.key
  169. SSLCertificateChainFile: /path/to/ssl.ca.crt
  170. ----
  171. === `+apache.config.vhosts.clean+`
  172. Remove non-declared virtual hosts, and deactivates the service.
  173. === `+apache.config.vhosts.cleanup+`
  174. Remove non-declared virtual hosts, but keeps the service running.
  175. == Testing
  176. Linux testing is done with `+kitchen-salt+`.
  177. === Requirements
  178. * Ruby
  179. * Docker
  180. [source,bash]
  181. ----
  182. $ gem install bundler
  183. $ bundle install
  184. $ bin/kitchen test [platform]
  185. ----
  186. Where `+[platform]+` is the platform name defined in `+kitchen.yml+`,
  187. e.g. `+debian-9-2019-2-py3+`.
  188. === `+bin/kitchen converge+`
  189. Creates the docker instance and runs the `+apache+` main states, ready
  190. for testing.
  191. === `+bin/kitchen verify+`
  192. Runs the `+inspec+` tests on the actual instance.
  193. === `+bin/kitchen destroy+`
  194. Removes the docker instance.
  195. === `+bin/kitchen test+`
  196. Runs all of the stages above in one go: i.e. `+destroy+` + `+converge+`
  197. + `+verify+` + `+destroy+`.
  198. === `+bin/kitchen login+`
  199. Gives you SSH access to the instance for manual testing.
  200. == Testing with Vagrant
  201. Windows/FreeBSD/OpenBSD testing is done with `+kitchen-salt+`.
  202. === Requirements
  203. * Ruby
  204. * Virtualbox
  205. * Vagrant
  206. === Setup
  207. [source,bash]
  208. ----
  209. $ gem install bundler
  210. $ bundle install --with=vagrant
  211. $ bin/kitchen test [platform]
  212. ----
  213. Where `+[platform]+` is the platform name defined in
  214. `+kitchen.vagrant.yml+`, e.g. `+windows-81-latest-py3+`.
  215. === Note
  216. When testing using Vagrant you must set the environment variable
  217. `+KITCHEN_LOCAL_YAML+` to `+kitchen.vagrant.yml+`. For example:
  218. [source,bash]
  219. ----
  220. $ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test # Alternatively,
  221. $ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
  222. $ bin/kitchen test
  223. ----
  224. Then run the following commands as needed.
  225. === `+bin/kitchen converge+`
  226. Creates the Vagrant instance and runs the `+apache+` main states, ready
  227. for testing.
  228. === `+bin/kitchen verify+`
  229. Runs the `+inspec+` tests on the actual instance.
  230. === `+bin/kitchen destroy+`
  231. Removes the Vagrant instance.
  232. === `+bin/kitchen test+`
  233. Runs all of the stages above in one go: i.e. `+destroy+` + `+converge+`
  234. + `+verify+` + `+destroy+`.
  235. === `+bin/kitchen login+`
  236. Gives you RDP/SSH access to the instance for manual testing.