apache-formula/docs/modules/ROOT/pages
semantic-release-bot 0cbac9c7af chore(release): 1.2.0 [skip ci]
# [1.2.0](https://github.com/saltstack-formulas/apache-formula/compare/v1.1.8...v1.2.0) (2021-08-28)

### Bug Fixes

* **suse:** use correct vhostdir and sitesdir for suse family ([#369](https://github.com/saltstack-formulas/apache-formula/issues/369)) ([fe0ceb7](fe0ceb78b7)), closes [/documentation.suse.com/sles/15-SP3/html/SLES-all/cha-apache2.html#sec-apache2](https://github.com//documentation.suse.com/sles/15-SP3/html/SLES-all/cha-apache2.html/issues/sec-apache2)

### Continuous Integration

* **3003.1:** update inc. AlmaLinux, Rocky & `rst-lint` [skip ci] ([2e116ec](2e116ec412))
* **freebsd:** update with latest pre-salted Vagrant boxes [skip ci] ([d679580](d67958043d))
* **gemfile+lock:** use `ssf` customised `inspec` repo [skip ci] ([5dd7009](5dd700944b))
* **kitchen:** move `provisioner` block & update `run_command` [skip ci] ([0d1a6dc](0d1a6dc75d))
* **kitchen+ci:** update with latest `3003.2` pre-salted images [skip ci] ([d3641d7](d3641d7f0d))
* add Debian 11 Bullseye & update `yamllint` configuration [skip ci] ([7741b90](7741b90ff6))

### Features

* **alma+rocky:** add platforms (based on CentOS 8) [skip ci] ([4353e57](4353e57a1b))
2021-08-28 23:25:45 +00:00
..
.keep docs(antora): add basic structure [skip ci] 2021-05-05 19:42:12 +01:00
AUTHORS.adoc chore(release): 1.2.0 [skip ci] 2021-08-28 23:25:45 +00:00
CHANGELOG.adoc chore(release): 1.2.0 [skip ci] 2021-08-28 23:25:45 +00:00
README.adoc chore(release): 1.1.7 [skip ci] 2021-05-14 14:47:42 +00:00

= apache

https://travis-ci.com/saltstack-formulas/apache-formula[image:https://travis-ci.com/saltstack-formulas/apache-formula.svg?branch=master[Travis CI Build Status]]
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]]

Formulas to set up and configure the Apache HTTP server on GNU/Linux,
FreeBSD, and Windows OS.

== General notes

See the full
https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html[SaltStack
Formulas installation and usage instructions].

If you are interested in writing or contributing to formulas, please pay
attention to the
https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#writing-formulas[Writing
Formula Section].

If you want to use this formula, please pay attention to the `FORMULA`
file and/or `git tag`, which contains the currently released version.
This formula is versioned according to http://semver.org/[Semantic
Versioning].

See
https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html#versioning[Formula
Versioning Section] for more details.

== Contributing to this repo

*Commit message formatting is significant!!*

Please see
xref:main::CONTRIBUTING.adoc[How
to contribute] for more details.

== Available states

=== `apache`

Installs the Apache package and starts the service.

=== `apache.config`

Metastate to apply all apache configuration

=== `apache.config.file`

Configures apache based on os_family

=== `apache.config.flags`

Configures apache flags on SuSE

=== `apache.config.certificates`

Deploy SSL certificates from pillars

=== `apache.config.modules`

Metastate to Enable and disable Apache modules.

=== `apache.config.modules.mod_mpm`

Configures the apache mpm modules on Debian `mpm_prefork`, `mpm_worker`
or `mpm_event` (Debian Only)

=== `apache.config.modules.mod_rewrite`

Enabled the Apache module mod_rewrite (Debian and FreeBSD only)

=== `apache.config.modules.mod_proxy`

Enables the Apache module mod_proxy. (Debian and FreeBSD only)

=== `apache.config.modules.mod_proxy_http`

Enables the Apache module mod_proxy_http and requires the Apache module
mod_proxy to be enabled. (Debian Only)

=== `apache.config.modules.mod_proxy_fcgi`

Enables the Apache module mod_proxy_fcgi and requires the Apache module
mod_proxy to be enabled. (Debian Only)

=== `apache.config.modules.mod_wsgi`

Installs the mod_wsgi package and enables the Apache module.

=== `apache.config.modules.mod_actions`

Enables the Apache module mod_actions. (Debian Only)

=== `apache.config.modules.mod_headers`

Enables the Apache module mod_headers. (Debian Only)

=== `apache.config.modules.mod_pagespeed`

Installs and Enables the mod_pagespeed module. (Debian and RedHat Only)

=== `apache.config.modules.mod_perl2`

Installs and enables the mod_perl2 module (Debian and FreeBSD only)

=== `apache.config.modules.mod_geoip`

Installs and enables the mod_geoIP (RedHat only)

=== `apache.config.modules.mod_php5`

Installs and enables the mod_php5 module

=== `apache.config.modules.mod_cgi`

Enables mod_cgi. (FreeBSD only)

=== `apache.config.modules.mod_fcgid`

Installs and enables the mod_fcgid module (Debian only)

=== `apache.config.modules.mod_fastcgi`

Installs and enables the mod_fastcgi module

=== `apache.config.modules.mod_dav_svn`

Installs and enables the mod_dav_svn module (Debian only)

=== `apache.config.modules.mod_security`

Installs an enables the http://modsecurity.org/[Apache mod_security2
WAF] using data from Pillar. (Debian and RedHat Only)

Allows you to install the basic Core Rules (CRS) and some basic
configuration for mod_security2

=== `apache.config.modules.mod_security.rules`

This state can create symlinks based on basic Core Rules package.
(Debian only) Or it can distribute a mod_security rule file and place it
/etc/modsecurity/

=== `apache.config.modules.mod_socache_shmcb`

Enables mod_socache_shmcb. (FreeBSD only)

=== `apache.config.modules.mod_ssl`

Installs and enables the mod_ssl module (Debian, RedHat and FreeBSD
only)

=== `apache.config.modules.mod_suexec`

Enables mod_suexec. (FreeBSD only)

=== `apache.config.modules.mod_vhost_alias`

Enables the Apache module vhost_alias (Debian Only)

=== `apache.config.modules.mod_remoteip`

Enables and configures the Apache module mod_remoteip using data from
Pillar. (Debian Only)

=== `apache.config.modules.mod_xsendfile`

Installs and enables mod_xsendfile module. (Debian Only)

=== `apache.config.own_default_vhost`

Replace default vhost with own version. By default, it's 503 code.
(Debian Only)

=== `apache.config.no_default_vhost`

Remove the default vhost. (Debian Only)

=== `apache.config.vhosts.standard`

Configures Apache name-based virtual hosts and creates virtual host
directories using data from Pillar.

Example Pillar:

[source,yaml]
----
apache:
  sites:
    example.com: # must be unique; used as an ID declaration in Salt; also passed to the template context as {{ id }}
      template_file: salt://apache/vhosts/standard.tmpl
----

When using the provided templates, one can use a space separated list of
interfaces to bind to. For example, to bind both IPv4 and IPv6:

[source,yaml]
----
apache:
  sites:
    example.com:
      interface: '1.2.3.4 [2001:abc:def:100::3]'
----

=== `apache.config.manage_security`

Configures Apache's security.conf options by reassinging them using data
from Pillar.

=== `apache.config.modules.mod_status`

Configures Apache's server_status handler for localhost

=== `apache.config.debian_full`

Installs and configures Apache on Debian and Ubuntu systems.

=== `apache.config.clean`

Metastate to cleanup all apache configuration.

=== `apache.clean`

Stops the Apache service and uninstalls the package.

These states are ordered using the `order` declaration. Different stages
are divided into the following number ranges:

[arabic]
. apache will use 1-500 for ordering
. apache will reserve 1 -100 as unused
. apache will reserve 101-150 for pre pkg install
. apache will reserve 151-200 for pkg install
. apache will reserve 201-250 for pkg configure
. apache will reserve 251-300 for downloads, git stuff, load data
. apache will reserve 301-400 for unknown purposes
. apache will reserve 401-450 for service restart-reloads
. apache WILL reserve 451-460 for service.running
. apache will reserve 461-500 for cmd requiring operational services

Example Pillar:

[source,yaml]
----
apache:
  register-site:
    # any name as an array index, and you can duplicate this section
    {{UNIQUE}}:
      name: 'my name'
      path: 'salt://path/to/sites-available/conf/file'
      state: 'enabled'

  sites:
    # Force SSL: Redirect from 80 to 443
    example.com:
      port: 80
      template_file: salt://apache/vhosts/redirect.tmpl
      RedirectSource: 'permanent /'
      # Trailing slash is important
      RedirectTarget: 'https://example.com/'
    example.com_ssl:
      port: 443
      ServerName: example.com
      SSLCertificateFile: /path/to/ssl.crt
      SSLCertificateKeyFile: /path/to/ssl.key
      SSLCertificateChainFile: /path/to/ssl.ca.crt
----

== Testing

Linux testing is done with `kitchen-salt`.

=== Requirements

* Ruby
* Docker

[source,bash]
----
$ gem install bundler
$ bundle install
$ bin/kitchen test [platform]
----

Where `[platform]` is the platform name defined in `kitchen.yml`, e.g.
`debian-9-2019-2-py3`.

=== `bin/kitchen converge`

Creates the docker instance and runs the `apache` main states, ready for
testing.

=== `bin/kitchen verify`

Runs the `inspec` tests on the actual instance.

=== `bin/kitchen destroy`

Removes the docker instance.

=== `bin/kitchen test`

Runs all of the stages above in one go: i.e. `destroy` + `converge` +
`verify` + `destroy`.

=== `bin/kitchen login`

Gives you SSH access to the instance for manual testing.

== Testing with Vagrant

Windows/FreeBSD/OpenBSD testing is done with `kitchen-salt`.

=== Requirements

* Ruby
* Virtualbox
* Vagrant

=== Setup

[source,bash]
----
$ gem install bundler
$ bundle install --with=vagrant
$ bin/kitchen test [platform]
----

Where `[platform]` is the platform name defined in
`kitchen.vagrant.yml`, e.g. `windows-81-latest-py3`.

=== Note

When testing using Vagrant you must set the environment variable
`KITCHEN_LOCAL_YAML` to `kitchen.vagrant.yml`. For example:

[source,bash]
----
$ KITCHEN_LOCAL_YAML=kitchen.vagrant.yml bin/kitchen test      # Alternatively,
$ export KITCHEN_LOCAL_YAML=kitchen.vagrant.yml
$ bin/kitchen test
----

Then run the following commands as needed.

=== `bin/kitchen converge`

Creates the Vagrant instance and runs the `apache` main states, ready
for testing.

=== `bin/kitchen verify`

Runs the `inspec` tests on the actual instance.

=== `bin/kitchen destroy`

Removes the Vagrant instance.

=== `bin/kitchen test`

Runs all of the stages above in one go: i.e. `destroy` + `converge` +
`verify` + `destroy`.

=== `bin/kitchen login`

Gives you RDP/SSH access to the instance for manual testing.