3

Is there a way to view the final "effective" config a running Apache instance is using after resolving any/all includes and the like?

I'm looking at a config that has a web of includes and suspect some of the issues I'm having are related to the order in which everything falls into place. I think it's apachectl that can validate a config has no syntax errors, but I'm wondering if I can go a step further and somehow output the fully assembled config. Any advice (short of cleaning up this mess of includes that should never have been allowed to happen)?

4

Yes, to a certain degree, but I think it covers your requirement. You can use mod_info for this.

From the online documentation (emphasis mine):

Dumping the configuration on startup

If the config define -DDUMP_CONFIG is set, mod_info will dump the pre-parsed configuration to stdout during server startup. Pre-parsed means that directives like <IfDefine> and <IfModule> are evaluated and environment variables are replaced. However it does not represent the final state of the configuration. In particular, it does not represent the merging or overriding that may happen for repeated directives.

This is roughly equivalent to the ?config query.

and:

[...]views of the configuration information are available by appending a query to the server-info request. For example, http://your.host.example.com/server-info?config will show all configuration directives.

?config

Just the configuration directives, not sorted by module

As an example, for a default configuration in Fedora 22, the lines marked as In file are included from the main httpd.conf file:

# curl -v http://localhost/server-info?config | elinks -dump
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying ::1...
* Connected to localhost (::1) port 80 (#0)
> GET /server-info?config HTTP/1.1
> User-Agent: curl/7.40.0
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 02 Jun 2015 20:49:43 GMT
< Server: Apache/2.4.12 (Fedora)
< Transfer-Encoding: chunked
< Content-Type: text/html; charset=ISO-8859-1
<
{ [8014 bytes data]
100  8561    0  8561    0     0  1792k      0 --:--:-- --:--:-- --:--:-- 2090k
* Connection #0 to host localhost left intact
                       Apache Server Information

   Configuration:
       In file: /etc/httpd/conf/httpd.conf
         42: Listen 80
         66: User apache
         67: Group apache
         86: ServerAdmin root@localhost
        102: <Directory />
        103:   AllowOverride none
        104:   Require all denied
           : </Directory>
        119: DocumentRoot "/var/www/html"
        124: <Directory "/var/www">
        125:   AllowOverride None
        127:   Require all granted
           : </Directory>
        131: <Directory "/var/www/html">
        144:   Options Indexes FollowSymLinks
        151:   AllowOverride None
        156:   Require all granted
           : </Directory>
        164: DirectoryIndex index.html
        171: <Files ".ht*">
        172:   Require all denied
           : </Files>
        182: ErrorLog "logs/error_log"
        189: LogLevel warn
        196: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
       \"%{User-Agent}i\"" combined
        197: LogFormat "%h %l %u %t \"%r\" %>s %b" common
        201: LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
       \"%{User-Agent}i\" %I %O" combinedio
        217: CustomLog "logs/access_log" combined
        247: ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
        255: <Directory "/var/www/cgi-bin">
        256:   AllowOverride None
        257:   Options None
        258:   Require all granted
           : </Directory>
        266: TypesConfig /etc/mime.types
        283: AddType application/x-compress .Z
        284: AddType application/x-gzip .gz .tgz
        305: AddType text/html .shtml
        306: AddOutputFilter INCLUDES .shtml
        316: AddDefaultCharset UTF-8
        324: MIMEMagicFile conf/magic
        348: EnableSendfile on
       In file: /etc/httpd/conf.d/autoindex.conf
         16: IndexOptions FancyIndexing HTMLTable VersionSort
         21: Alias /icons/ "/usr/share/httpd/icons/"
         23: <Directory "/usr/share/httpd/icons">
         24:   Options Indexes MultiViews FollowSymlinks
         25:   AllowOverride None
         26:   Require all granted
           : </Directory>
         34: AddIconByEncoding (CMP,/icons/compressed.gif) x-compress
       x-gzip
         36: AddIconByType (TXT,/icons/text.gif) text/*
         37: AddIconByType (IMG,/icons/image2.gif) image/*
         38: AddIconByType (SND,/icons/sound2.gif) audio/*
         39: AddIconByType (VID,/icons/movie.gif) video/*
         41: AddIcon /icons/binary.gif .bin .exe
         42: AddIcon /icons/binhex.gif .hqx
         43: AddIcon /icons/tar.gif .tar
         44: AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
         45: AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
         46: AddIcon /icons/a.gif .ps .ai .eps
         47: AddIcon /icons/layout.gif .html .shtml .htm .pdf
         48: AddIcon /icons/text.gif .txt
         49: AddIcon /icons/c.gif .c
         50: AddIcon /icons/p.gif .pl .py
         51: AddIcon /icons/f.gif .for
         52: AddIcon /icons/dvi.gif .dvi
         53: AddIcon /icons/uuencoded.gif .uu
         54: AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
         55: AddIcon /icons/tex.gif .tex
         56: AddIcon /icons/bomb.gif core.
         58: AddIcon /icons/back.gif ..
         59: AddIcon /icons/hand.right.gif README
         60: AddIcon /icons/folder.gif ^^DIRECTORY^^
         61: AddIcon /icons/blank.gif ^^BLANKICON^^
         67: DefaultIcon /icons/unknown.gif
         85: ReadmeName README.html
         86: HeaderName HEADER.html
         92: IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
       In file: /etc/httpd/conf.d/mod_dnssd.conf
          2: DNSSDEnable on
       In file: /etc/httpd/conf.d/userdir.conf
         17: UserDir disabled
         31: <Directory "/home/*/public_html">
         32:   AllowOverride FileInfo AuthConfig Limit Indexes
         33:   Options MultiViews Indexes SymLinksIfOwnerMatch
       IncludesNoExec
         34:   Require method GET POST OPTIONS
           : </Directory>
       In file: /etc/httpd/conf.d/welcome.conf
          8: <LocationMatch "^/+$">
          9:   Options -Indexes
         10:   ErrorDocument 403 /.noindex.html
           : </LocationMatch>
         13: <Directory /usr/share/httpd/noindex>
         14:   AllowOverride None
         15:   Require all granted
           : </Directory>
         18: Alias /.noindex.html /usr/share/httpd/noindex/index.html
       In file: /etc/httpd/conf/httpd.conf
        355: <Location "/server-info">
        356:   SetHandler server-info
           : </Location>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.