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 10KB

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