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

class insights.parsers.httpd_conf.HttpdConf(*args, **kwargs)[source]

Bases: HttpdConfBase

class insights.parsers.httpd_conf.HttpdConfBase(*args, **kwargs)[source]

Bases: ConfigParser

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/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

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

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
</IfModule>

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

Examples

>>> httpd_conf['ServerRoot'][-1].value
'/etc/httpd'
>>> httpd_conf['LoadModule'][0].value
'auth_basic_module modules/mod_auth_basic.so'
>>> httpd_conf['LoadModule'][-1].value
'auth_digest_module modules/mod_auth_digest.so'
>>> httpd_conf['Directory', '/']['Options'][-1].value
'FollowSymLinks'
>>> type(httpd_conf[('IfModule','prefork.c')]) == type({})
False
>>> httpd_conf[('IfModule','prefork.c')]['StartServers'][0].value
8
>>> 'ThreadsPerChild' in httpd_conf[('IfModule','prefork.c')]
False
>>> httpd_conf[('IfModule','worker.c')]['MaxRequestsPerChild'][-1].value
0
class insights.parsers.httpd_conf.HttpdConfSclHttpd24(*args, **kwargs)[source]

Bases: HttpdConfBase

class insights.parsers.httpd_conf.HttpdConfSclJbcsHttpd24(*args, **kwargs)[source]

Bases: HttpdConfBase