やりたいこと
h2oでServerヘッダーに出力される情報を限定させたい。
nginxでのserver_tokens off;設定のようなことを行いたいです。
試したこと
Server ヘッダーに対してunsetやsetを実施すると、次のようなエラーとなってしまう
log
1[/etc/h2o.conf:28] in command header.unset, the named header cannot be rewritten 22019-03-06 15:44:03,804 INFO exited: h2o (exit status 78; not expected)
設定ファイル(h2o.conf):
h2o.conf
1pid-file: /tmp/h2o.pid 2#access-log: /dev/stdout 3access-log: /dev/null 4error-log: /dev/stderr 5user: www-data 6 7file.custom-handler: 8 extension: .php 9 header.unset: "x-powered-by" 10 fastcgi.connect: 11 port: /var/run/php-fpm/php-fpm.sock 12 type: unix 13 14compress: on 15file.index: [ 'index.html', 'index.htm', 'index.txt', 'index.php' ] 16 17hosts: 18 "local:80": 19 listen: 20 port: 80 21 host: 0.0.0.0 22 paths: 23 "/": 24 mruby.handler: | 25 acl { 26 respond(403, {}, ["Not allowed"]) { path.start_with?("/cacti/config") } 27 } 28 file.dir: /var/www/html 29 header.unset: "Server" 30 redirect: 31 url: /cacti 32 internal: no 33 status: 307 34
試験環境
一応、play-with-docker で試すことができます。
sh
1wget https://github.com/indication/docker-cacti/archive/master.tar.gz 2tar xzf master.tar.gz 3rm master.tar.gz 4cd docker-cacti-master/ 5ls 6vi h2o.conf 7# 上記のように編集します 8docker-compose build 9# ビルド時間は恐れ入りますが5分程度かかります 10# docker-compose up -dに失敗することがありますので、再度実行していただければ回復します 11docker-compose up -d 12docker-compose logs cacti
参考文献
- Configure > Headers Directives H2O公式マニュアルのヘッダー設定
- directives for tweaking the server header #239 (github)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。