INDEX
その他:4.7 (Apache 1.3.29), 6.8+tsl+cgi, 7.7+tsl+cgi
OpenBSD Web サーバ (httpd on OpenBSD 7.7)
OpenBSD の Webサーバ httpd(relayd) で、Webサーバを動かす。
OpenBSD に初期で組み込まれている Web サーバが、Apache 1.3系 から(nginx になって)、OpenBSD 5.6 に独自のもの relayd(8) ベースに変更されている。
CGI の実行は OpenBSD/httpd/77(relayd+slowcgi) を。SSL(TSL) 接続は OpenBSD/httpd/77(relayd+tsl) も参照。
- 関連 man → httpd(8), httpd.conf(5)
httpd の起動設定
自動起動
サーバが起動したときに httpd も実行されるように、/etc/rc.conf.local に httpd_flags を指定する。
# httpd web server httpd_flags=
または、rcctl enable httpd で有効にする( /etc/rc.conf.local に httpd_flags= が記載される)。
デバッグ
root ユーザのコンソールで、-dvv オプションをつけて実行すると、処理の内容が表示される。
# httpd -dvv startup :後略
Webサーバ(httpd) の設定
/etc/httpd.conf に設定する。サンプルが /etc/examples/httpd.conf にある。
OpenBSD の httpd は、 /var/www に chroot されるようになっている。
静的ドキュメント
/var/www/htdocs 以下の静的ドキュメントを表示させる(/var/www に chroot され、ドキュメントルートは /htdocs)。
動的ドキュメント
slowcgi を使い CGI を実行させる。OpenBSD/httpd/77(relayd+slowcgi) を参照。
SSL(TSL) 接続
SSL(TSL) 接続の設定 および ACME client を用いて Let's Encrypt の証明書の取得と更新。OpenBSD/httpd/77(relayd+tsl) を参照。
リダイレクト
特定の URL のパスにアクセスされた場合に、別ページ もしくは 別サーバにリダイレクトさせる。
「/index.htm」のアクセスを「/index.html」へ、「/example/***」のアクセスを https://example.com/ の同じパス(/example/sample.html を https://example.com/sample.html へ)へリダイレクトさせる。
server "default" {
# :中略
location "/index.htm" {
block return 301 "/index.html"
}
location match "/example/(.*)" {
block return 302 "https://example.com/%1"
}
# :中略
}
最終更新時間:2025年07月08日 23時18分21秒 指摘や意見などあればSandBoxのBBSへ。