2016-09-22 12:43:57 +00:00
---
title: About the apache_conf Resource
2018-02-16 00:28:15 +00:00
platform: linux
2016-09-22 12:43:57 +00:00
---
# apache_conf
2019-04-26 18:24:29 +00:00
Use the `apache_conf` Chef InSpec audit resource to test the configuration settings for Apache. This file is typically located under `/etc/apache2` on the Debian and Ubuntu platforms and under `/etc/httpd` on the Fedora, CentOS, RedHat Enterprise Linux, and ArchLinux platforms. The configuration settings may vary significantly from platform to platform.
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
<br>
2018-08-09 12:34:49 +00:00
## Availability
### Installation
2019-04-26 18:24:29 +00:00
This resource is distributed along with Chef InSpec itself. You can use it automatically.
2018-08-09 12:34:49 +00:00
### Version
This resource first became available in v1.0.0 of InSpec.
2016-09-27 19:03:23 +00:00
## Syntax
2016-09-22 12:43:57 +00:00
2019-04-26 18:24:29 +00:00
An `apache_conf` Chef InSpec audit resource block declares configuration settings that should be tested:
2016-09-22 12:43:57 +00:00
describe apache_conf('path') do
its('setting_name') { should eq 'value' }
end
where
* `'setting_name'` is a configuration setting defined in the Apache configuration file
* `('path')` is the non-default path to the Apache configuration file
* `{ should eq 'value' }` is the value that is expected
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Examples
2016-09-22 12:43:57 +00:00
2019-04-26 18:24:29 +00:00
The following examples show how to use this Chef InSpec audit resource.
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test for blocking .htaccess files on CentOS
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
describe apache_conf do
2018-01-29 18:03:36 +00:00
its('AllowOverride') { should cmp 'None' }
2017-10-03 21:35:10 +00:00
end
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
### Test ports for SSL
2016-09-22 12:43:57 +00:00
describe apache_conf do
2018-01-29 18:03:36 +00:00
its('Listen') { should cmp '443' }
end
### Test multiple ports are listening
describe apache_conf do
its('Listen') { should =~ [ '80', '443' ] }
2016-09-22 12:43:57 +00:00
end
2017-10-03 21:35:10 +00:00
<br>
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
## Matchers
2016-09-22 12:43:57 +00:00
2018-02-16 03:07:18 +00:00
For a full list of available matchers, please visit our [matchers page](https://www.inspec.io/docs/reference/matchers/).
2019-04-26 18:24:29 +00:00
This Chef InSpec audit resource matches any service that is listed in the Apache configuration file:
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
its('PidFile') { should_not eq '/var/run/httpd.pid' }
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
or:
2016-09-22 12:43:57 +00:00
2018-01-29 18:03:36 +00:00
its('Timeout') { should cmp '300' }
2016-09-22 12:43:57 +00:00
2017-10-03 21:35:10 +00:00
For example:
2016-09-22 12:43:57 +00:00
describe apache_conf do
2018-01-29 18:03:36 +00:00
its('MaxClients') { should cmp '100' }
its('Listen') { should cmp '443' }
2016-09-22 12:43:57 +00:00
end