0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Apache だけで Let's Encrypt で HTTPS のサーバー証明書取得 (mod_md 使用)

0
Posted at

前置き

ウェブサーバーを立てるのに証明書どうしようかなー、と探していたら Certbot とか使わずに Apache だけで Let's Encrypt の証明書を取得できるらしい。
やってみた。

mod_md を使う

Apache HTTP Server 付属のモジュール mod_md を使うと Let's Encrypt などと ACME で連携してサーバー証明書の取得・更新ができる。
他に OCSP Stapling も使える。

mod_md は2018年2月リリースの Apache 2.4.30 から利用可能。12
公式ドキュメントでは Experimental というステータスになっている。3

RHEL 系なら 8 から付属パッケージがあるはず。

準備

今回は AlmaLinux 10.1 を使用した。
OS をインストールし、IP アドレスを DNS に登録しておく。
インターネットから 80/tcp, 443/tcp にアクセスできるようにしておく。

Let's Encrypt の規約4を読んでおく。

やってみる

パッケージをインストール。

# dnf install -y httpd mod_md

サーバー名を設定。

# vi /etc/httpd/conf/httpd.conf
ServerName test1.example.com

mod_md の設定を作成。
MDCertificateAgreement accepted とすると Let's Encrypt の規約に同意したことになる。

# vi /etc/httpd/conf.d/md.conf
MDomain test1.example.com
MDContactEmail admin@example.com
MDCertificateAgreement accepted

httpd が外部と通信を行うので、SELinux が有効の場合は下記を実行。

# setsebool -P httpd_can_network_connect on

httpd を起動。

# systemctl enable httpd
# systemctl start httpd

ちょっとすると /var/log/httpd/error_log に下記のようなメッセージが出る。

[Sat Jan 03 11:52:56.928436 2026] [md:notice] [pid 2303:tid 2306] AH10059: The Managed Domain test1.example.com has been setup and changes will be activated on next (graceful) server restart.

httpd を再起動すると取得した証明書を使用したサービスが始まる。

# systemctl restart httpd

取得した証明書などは下記にある。

# ls /var/lib/httpd/md/domains/test1.example.com/
job.json  md.json  privkey.pem  pubcert.pem
  1. https://github.com/apache/httpd/releases/tag/2.4.30

  2. https://httpd.apache.org/docs/2.4/new_features_2_4.html

  3. https://httpd.apache.org/docs/2.4/mod/mod_md.html

  4. https://letsencrypt.org/repository/

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?