WordPress nginx CentOS7 SSL自動更新失敗して、手動更新しました

戻る
公開日:2022/1/22
WordPress nginx CentOS7 SSL自動更新失敗して、手動更新しました

以前、SSLを対応させて、自動更新を設定しました。

しかし、以下のエラーが出て、自動更新ができておらず、ブログが見れなくなっていました。

[******** ~]# certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/fuuu.work.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator standalone, Installer None
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Account registered.
Simulating renewal of an existing certificate for fuuu.work and 2 more domains
Performing the following challenges:
http-01 challenge for fuiro.fuuu.work
http-01 challenge for fuuu.work
Cleaning up challenges
Failed to renew certificate fuuu.work with error: Problem binding to port 80: Could not bind to IPv4 or IPv6.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
All simulated renewals failed. The following certificates could not be renewed:
  /etc/letsencrypt/live/fuuu.work/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)

原因はポート80でSSL更新を行うそうですが、ポート80を他で使っていたからでした。

ポート80を調べてみます。

[****** ~]# lsof -i :80
COMMAND   PID  USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
nginx    1870  root    8u  IPv4 280544960      0t0  TCP *:http (LISTEN)
nginx   29337 nginx    8u  IPv4 280544960      0t0  TCP *:http (LISTEN)

nginxが使っています。そういえば、ポート80を開けておいて、httpsに転送する設定にしていました。。

ということで、nginxの設定ファイルでポート80を止めることにします。
ポート80の部分をコメントアウトにします。

view /etc/nginx/conf.d/fuiro.conf
#    server {
#        listen 80;
#        server_name fuuu.work;
#        return 301 https://$host$request_uri;
#        root /var/contents/;
#
#    }

保存したら、nginxを再起動します

# systemctl restart nginx

再度、ポート80を使用しているか確認します。なくなりました。

# lsof -i :80

SSL証明書の更新をします。まずは–dry-runでテストします。

#certbot renew --dry-run
Saving debug log to /var/log/letsencrypt/letsencrypt.log

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/fuuu.work.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cert is due for renewal, auto-renewing...
Plugins selected: Authenticator standalone, Installer None
Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
Simulating renewal of an existing certificate for fuuu.work and 2 more domains
Performing the following challenges:
http-01 challenge for fuiro.fuuu.work
http-01 challenge for fuuu.work
Waiting for verification...
Cleaning up challenges

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
new certificate deployed without reload, fullchain is
/etc/letsencrypt/live/fuuu.work/fullchain.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all simulated renewals succeeded: 
  /etc/letsencrypt/live/fuuu.work/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

successになったので、実際にSSL証明書の更新を行います。

# certbot renew

同様にsuccessが表示されたら、nginxを再起動します。

# systemctl restart nginx

サイトが見れるようになりました。
cronで更新コマンドは起動させているので、次回からは自動更新できるはずです。

戻る