HttpdConf - files /etc/httpd/conf/httpd.conf and /etc/httpd/conf.d/*

Parse the keyword-and-value-but-also-vaguely-XML of an Apache configuration file.

Generally, each line is split on the first space into key and value, leading and trailing space being ignored.

Sample (edited) httpd.conf file:

ServerRoot "/etc/httpd"
LoadModule auth_basic_module modules/
LoadModule auth_digest_module modules/

<Directory />
    Options FollowSymLinks
    AllowOverride None

<IfModule mod_mime_magic.c>
#   MIMEMagicFile /usr/share/magic.mime
    MIMEMagicFile conf/magic

ErrorLog "|/usr/sbin/httplog -z /var/log/httpd/error_log.%Y-%m-%d"

SSLProtocol -ALL +SSLv3
#SSLProtocol all -SSLv2

NSSProtocol SSLV3 TLSV1.0
#NSSProtocol ALL

# prefork MPM
<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  200

# worker MPM
<IfModule worker.c>
StartServers         4
MaxClients         300
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0


>>> httpd_conf['ServerRoot'][-1].value
>>> httpd_conf['LoadModule'][0].value
'auth_basic_module modules/'
>>> httpd_conf['LoadModule'][-1].value
'auth_digest_module modules/'
>>> httpd_conf['Directory', '/']['Options'][-1].value
>>> type(httpd_conf[('IfModule','prefork.c')]) == type({})
>>> httpd_conf[('IfModule','mod_mime_magic.c')]
{'MIMEMagicFile': [ParsedData(value='conf/magic', line='MIMEMagicFile conf/magic', section='IfModule', section_name='mod_mime_magic.c', file_name='path', file_path='/path')]}
>>> httpd_conf[('IfModule','prefork.c')]['StartServers'][0].value
>>> 'ThreadsPerChild' in httpd_conf[('IfModule','prefork.c')]
>>> httpd_conf[('IfModule','worker.c')]['MaxRequestsPerChild'][-1].value
class insights.parsers.httpd_conf.HttpdConf(*args, **kwargs)[source]

Bases: insights.core.LegacyItemAccess, insights.core.Parser


This parser is deprecated, please use insights.combiners.httpd_conf.HttpdConfTree instead.

Get the key value pairs separated on the first space, ignoring leading and trailing spaces.

If the file is httpd.conf, it also stores first half, before IncludeOptional conf.d/*.conf line, and the rest, to the first_half and second_half attributes respectively.


Dictionary of parsed data with key being the option and value a list of named tuples with the following properties: - value - the value of the keyword. - line - the complete line as found in the config file. The reason why it is a list is to store data for directives which can use selective overriding such as UserDir.




Parsed data from main config file before inclusion of other files in the same format as data.




Parsed data from main config file after inclusion of other files in the same format as data.




This method must be implemented by classes based on this class.

class insights.parsers.httpd_conf.ParsedData(value, line, section, section_name, file_name, file_path)

Bases: tuple

namedtuple: Type for storing the parsed httpd configuration’s directive information.

property file_name
property file_path
property line
property section
property section_name
property value
insights.parsers.httpd_conf.dict_deep_merge(tgt, src)[source]

Utility function to merge the source dictionary src to the target dictionary recursively


The type of the values in the dictionary can only be dict or list

  • tgt (dict) -- The target dictionary

  • src (dict) -- The source dictionary