なみひらブログ

学んだことを日々記録する。~ since 2012/06/24 ~

Amazon Linux 2 + Apache + Route53環境にLet's Encrypt を入れたときの作業メモ

背景

自分のサイトをhttpsでアクセスできるようにしたかったので、Let's Encryptを使ってhttps化したときもメモです

作業メモ

基本作業

AWSに公式ページがあるので、まずその作業をした。
チュートリアル: Amazon Linux 2 で SSL/TLS を使用できるように Apache ウェブサーバーを設定する - Amazon Elastic Compute Cloud

以下がその差分です。
example.comは例。

certbotコマンド

「sudo certbot」だと以下のように言われたので、

Saving debug log to /var/log/letsencrypt/letsencrypt.log Certbot doesn't know how to automatically configure the web server on this system. However, it can still get a certificate for you. 
Please run "certbot certonly" to do so. You'll need to manually configure your web server to use the resulting certificate.

以下を実行した。

sudo certbot certonly --agree-tos --webroot -w /var/www/html/ -d www.example.com

httpdの設定

ドメインからIPが引けないといけないらしいので、Route53でIPに紐づけている「www.**」にて設定した。
443ポート対応追加。httpもあると便利だったりするので残した。

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName "www.example.com"
</VirtualHost>

<VirtualHost *:443>
  DocumentRoot "/var/www/html"
  ServerName "www.example.com"

  ErrorLog  "logs/ssl_error_log"
  CustomLog "logs/ssl_access_log" combined

  # SSL
  SSLEngine on
  SSLCertificateFile /etc/letsencrypt/live/www.example.com/cert.pem
  SSLCertificateChainFile /etc/letsencrypt/live/www.example.com/chain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/www.example.com/privkey.pem
</VirtualHost>

まとめ

ソースコード直書きで「http」でアクセスしているところもこれから直す(´・ω・`)

参考