2013-08-27 16:27:53 -06:00
|
|
|
======
|
2013-06-12 15:05:04 -07:00
|
|
|
apache
|
2013-07-29 21:34:54 +00:00
|
|
|
======
|
2013-07-27 18:12:01 +00:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Formulas to set up and configure the Apache HTTP server.
|
2019-02-22 10:10:30 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
This Formula uses the concepts of ``directive`` and ``container`` in pillars
|
2019-02-22 10:10:30 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
* ``directive`` is an httpd directive https://httpd.apache.org/docs/2.4/en/mod/directives.html
|
|
|
|
* ``container`` is what described the `configuration sections` https://httpd.apache.org/docs/2.4/en/sections.html
|
|
|
|
|
|
|
|
see examples below for more explanation
|
|
|
|
|
|
|
|
Also it includes and enforce some hardening rules to prevent security issues
|
|
|
|
|
|
|
|
See `<Hardening.md>`_ and `<apache/hardening-values.yaml>`_.
|
2013-07-29 21:34:54 +00:00
|
|
|
|
2013-08-13 15:12:57 -06:00
|
|
|
.. note::
|
2013-07-29 21:34:54 +00:00
|
|
|
|
2013-08-13 15:12:57 -06:00
|
|
|
See the full `Salt Formulas installation and usage instructions
|
2014-08-06 17:08:06 -04:00
|
|
|
<http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
|
2013-07-29 21:34:54 +00:00
|
|
|
|
2013-08-13 15:12:57 -06:00
|
|
|
Available states
|
2013-08-27 16:27:53 -06:00
|
|
|
================
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:local:
|
2013-07-29 21:34:54 +00:00
|
|
|
|
2013-08-13 15:12:57 -06:00
|
|
|
``apache``
|
2013-08-27 16:27:53 -06:00
|
|
|
----------
|
|
|
|
|
|
|
|
Installs the Apache package and starts the service.
|
|
|
|
|
2015-06-19 20:44:53 +02:00
|
|
|
``apache.config``
|
|
|
|
-----------------
|
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Configures apache server.
|
2015-06-19 20:44:53 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
The configuration is done by merging the pillar content with defaults
|
|
|
|
present in the state `<apache/defaults/RedHat/defaults-apache-2.4.yaml>`_
|
2017-03-09 12:44:32 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
.. code:: yaml
|
2017-03-09 12:44:32 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
apache:
|
|
|
|
server_apache_config:
|
|
|
|
directives:
|
|
|
|
- Timeout: 5
|
|
|
|
containers:
|
|
|
|
IfModule:
|
|
|
|
-
|
|
|
|
item: 'mime_module'
|
|
|
|
directives:
|
|
|
|
- AddType: 'application/x-font-ttf ttc ttf'
|
|
|
|
- AddType: 'application/x-font-opentype otf'
|
|
|
|
- AddType: 'application/x-font-woff woff2'
|
2015-06-19 20:44:53 +02:00
|
|
|
|
|
|
|
|
2014-11-20 15:37:14 -08:00
|
|
|
``apache.modules``
|
|
|
|
------------------
|
|
|
|
|
|
|
|
Enables and disables Apache modules.
|
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
``apache.vhosts.vhost``
|
|
|
|
--------------------------
|
2015-12-24 12:53:33 +03:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Configures Apache name-based virtual hosts and creates virtual host directories using data from Pillar.
|
2016-09-23 11:12:37 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
All necessary data must be provided in the pillar
|
2016-09-23 11:12:37 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Exceptions are :
|
2016-09-27 00:56:52 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
* ``CustomLog`` default is ``/path/apache/log/ServerName-access.log combined``
|
2016-09-27 00:56:52 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
* if ``Logformat`` is defined in pillar, ``CustomLog`` is enforced to ``/path/apache/log/ServerName-access.log Logformat``
|
2016-05-18 10:07:24 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
* ``ErrorLog`` is enforced to ``/path/apache/log/ServerName-error.log``
|
2016-05-18 10:07:24 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Example Pillar:
|
2017-01-08 12:13:38 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Create two vhosts ``example.com.conf`` and ``test.example.com.conf``
|
2017-01-08 12:13:38 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
.. code:: yaml
|
2015-06-19 20:44:53 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
apache:
|
|
|
|
VirtualHost:
|
|
|
|
example.com: # <-- this is an id decalaration used in salt and default ServerName
|
|
|
|
item: '*:80'
|
|
|
|
directives:
|
|
|
|
- RewriteEngine: 'on'
|
|
|
|
- Header: 'set Access-Control-Allow-Methods GET,PUT,POST,DELETE,OPTIONS'
|
|
|
|
containers:
|
|
|
|
Location:
|
|
|
|
item: '/test.html'
|
|
|
|
directives:
|
|
|
|
- Require: 'all granted'
|
|
|
|
site_id_declaration:
|
|
|
|
item: '10.10.1.1:8080'
|
|
|
|
directives:
|
|
|
|
- ServerName: 'test.example.com'
|
|
|
|
- LogFormat: '"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{ms}T"'
|
2015-06-19 20:44:53 +02:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
Files produced by these pillars :
|
2015-12-16 02:54:14 +03:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
``example.com.conf``
|
2015-12-16 02:54:14 +03:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
.. code:: bash
|
2017-02-07 16:03:30 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
<VirtualHost *:80>
|
|
|
|
ServerName example.com
|
|
|
|
CustomLog /var/log/httpd/example.com-access.log combined
|
|
|
|
ErrorLog /var/log/httpd/example.com-error.log
|
|
|
|
RewriteEngine on
|
|
|
|
Header set Access-Control-Allow-Methods GET,PUT,POST,DELETE,OPTIONS
|
|
|
|
<Location /test.html>
|
|
|
|
Require all granted
|
|
|
|
</Location>
|
|
|
|
</VirtualHost>
|
2017-02-07 16:03:30 +01:00
|
|
|
|
2013-08-27 16:27:53 -06:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
``test.example.com.conf``
|
2013-08-27 16:27:53 -06:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
.. code:: bash
|
2016-02-16 13:09:52 +01:00
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
<VirtualHost 10.10.1.1:8080>
|
|
|
|
ServerName test.example.com
|
|
|
|
CustomLog /var/log/httpd/test.example.com-access.log "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{ms}T"
|
|
|
|
ErrorLog /var/log/httpd/test.example.com-error.log
|
|
|
|
</VirtualHost>
|
2016-02-16 13:09:52 +01:00
|
|
|
|
2015-12-14 17:44:59 +03:00
|
|
|
|
|
|
|
|
2019-04-20 09:38:32 +02:00
|
|
|
this will delete ``test.example.com.conf``
|
2013-08-27 16:27:53 -06:00
|
|
|
|
|
|
|
.. code:: yaml
|
|
|
|
|
|
|
|
apache:
|
2019-04-20 09:38:32 +02:00
|
|
|
VirtualHost:
|
|
|
|
test.example.com:
|
|
|
|
item: '10.10.1.1:8080'
|
|
|
|
absent: True # <-- delete test.example.com.conf
|
|
|
|
directives:
|
|
|
|
- ServerName: 'test.example.com'
|
2013-08-27 16:27:53 -06:00
|
|
|
|
2019-02-22 10:10:30 +01:00
|
|
|
|
2013-08-27 16:27:53 -06:00
|
|
|
|
2017-04-05 12:00:50 +03:00
|
|
|
``apache.uninstall``
|
|
|
|
----------
|
|
|
|
|
|
|
|
Stops the Apache service and uninstalls the package.
|