LoginSignup
6
7

More than 5 years have passed since last update.

Apache: 現在の設定を server-info で取得する

Posted at

やりたいこと

Serverspec とかでサーバ設定のテストとか書くときに Apache で現在適用されている設定を出力したい。
設定ファイルの状態じゃなくて、今何が効いてるかが知りたい。apachectl でも出そうで出ない。
sshd でいうところのコレがほしい。

sshd -T

やりかた

sshd みたいに httpd になんか引数つけて実行したら出るかと思ったらダメそう。
結局よくわからないので、mod_info モジュールでやってみる。
 
https://httpd.apache.org/docs/2.2/ja/mod/mod_info.html

http://your.host.example.com/server-info にアクセスすることでサーバの情報を得られるようになります。

取得できる情報。

?<module-name>
指定されたモジュールに関連する情報のみ
?config
モジュールでソートせずに、設定ディレクティブのみ
?hooks
各モジュールが使用するフックのみ
?list
有効なモジュールの簡単なリストのみ
?server
基本サーバ情報のみ

設定

/path/to/httpd/conf.d/server-info.conf とか適当において、httpdを再起動します。
(セキュリティを考慮しましょう)

<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
</Location>

実践

出力が HTML なので、そのままだとパースしづらい。いい感じに整形して。

curl -s http://127.0.0.1/server-info/?mod_ssl.c | perl -pe 's/<[^>]+>//g; s/\&nbsp;/ /g'

w3m でもいいぞ。

curl -s http://127.0.0.1/server-info/?list | w3m -dump -T text/html

やってみたものの、何か役に立つのだろうか。

$ curl -s http://127.0.0.1/server-info/?config | w3m -dump -T text/html  | grep -i SSLProtocol
      25:   SSLProtocol +ALL -SSLv2
$

Serverspec で。

describe command('curl -s http://127.0.0.1/server-info/?mod_ssl.c | w3m -dump -T text/html') do
  its(:stdout) { should match /SSLProtocol \+ALL \-SSLv2/ }
end

イマイチ感。
捗れ〜。

6
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
7