LoginSignup
4

More than 3 years have passed since last update.

CentOS8とnginxでLet’s Encrypt

Posted at

Certbot - Centosrhel8 Nginx
に従ってそのままやる。

// インストール
# wget https://dl.eff.org/certbot-auto
# mv certbot-auto /usr/local/bin/certbot-auto
# chown root /usr/local/bin/certbot-auto
# chmod 0755 /usr/local/bin/certbot-auto

// ポート開ける
# firewall-cmd --add-service=https --zone=public --permanent
# firewall-cmd --add-service=http  --zone=public --permanent
# firewall-cmd --reload

// いくつかパッケージをインストール要求
# /usr/local/bin/certbot-auto certonly --nginx

// nginx設定編集
# vi /etc/nginx/nginx.conf
        ssl_certificate "/etc/letsencrypt/live/www.hogehoge.com/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/www.hogehoge.com/privkey.pem";

// 起動してhttpsアクセスできれば成功
# systemctl start nginx

// 自動更新のcron設定(ここはpython3にして設定)
# vi /etc/cron.d/lets-encrypt
0 0,12 * * * root python3 -c 'import random; import time; time.sleep(random.random() * 3600)' && /usr/local/bin/certbot-auto renew >/dev/null 2>&1

参考

Let's Encrypt で Nginx にSSLを設定する - Qiita

CentOS 7に「killall」コマンドをインストールする | 俺的備忘録 〜なんかいろいろ〜

こんなメッセージが出てきたらfirewall設定足りてないかも。

IMPORTANT NOTES:
 - The following errors were reported by the server:

   Domain: www.hogehoge.com
   Type:   connection
   Detail: Fetching
   http://www.hogehoge.com.well-known/acme-challenge/xxxxxxxxxxxxxxxxxxxxxx:
   Error getting validation data

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.

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
4