1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Let's Encrypt導入前に準備すべきこと

Last updated at Posted at 2019-01-07

リリースチェッカーというサービスを個人で運営しています。先日、HTTPS化のため、Let's Encryptのサーバ証明書を導入しました。

手順は簡単だったのですが、事前に準備しておけば、もっとスムーズに進められたはずです。準備しておくべきだった3つの項目をご紹介します。

環境

  • CentOS 6.10
  • httpd 2.2.15
  • certbot 0.30.0

導入手順(参考)

$ cd /usr/local/bin
$ sudo wget https://dl.eff.org/certbot-auto
$ sudo chmod a+x certbot-auto
$ sudo ./certbot-auto --apache -d a.noare.net

準備しておくべきだった項目

1. バーチャルホストの設定

certbot-auto コマンドの初回実行時に、下記のエラーが出てしまいました。

Unable to find a virtual host listening on port 80 which is currently needed for Certbot to prove to the CA that you control your domain. Please add a virtual host for port 80.

原因はバーチャルホストで運用していなかったためです。 /etc/httpd/conf/httpd.conf<VirtualHost> ディレクティブを追加することで解消しました。

2. mod_rewriteの有効化

再度 certbot-auto コマンドを実行すると、違うエラーが出てしまいました。

Syntax error on line 1 of /etc/httpd/conf.d/le_http_01_challenge_pre.conf:
Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

原因はmod_rewriteを無効にしていたためです。 /etc/httpd/conf/httpd.conf 内の下記の行をアンコメントすることで解消しました。

# LoadModule rewrite_module modules/mod_rewrite.so

3. mod_sslの設定

さらに certbot-auto コマンドを実行すると、HTTPSをリッスンするようにはなったものの、自己署名証明書が有効になってしまいました。

原因は、mod_sslのインストール時に作られた /etc/httpd/conf.d/ssl.conf<VirtualHost _default_:443> セクションが存在し、その中に下記の行があったためでした。

SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

<VirtualHost _default_:443> セクションをまるごと削除することで、Let's Encryptの証明書が有効になり、問題が解消しました。

事前にmod_sslをインストールし、 ssl.conf を編集しておくのが無難だろうと思います。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?