AWS EC 2インスタンスにおけるletの暗号化の使用



目的
  • EC 2インスタンスにSSL証明書を作成します.
  • 私たちは、このECインスタンス(ドキュメントとは異なり)でPHPを使用することを検討しません.

  • 文書
    Tutorial: Configure SSL/TLS on Amazon Linux 2
    しかし、ドキュメントのここの指示のいくつかは時代遅れでした.

    必要条件
  • は既にEC 2インスタンスを開始しました(この状況の場合、アマゾンLinux 2)
  • EC 2セキュリティグループは、ポート80、443、および22オープン(HTTP、HTTPS、およびSSH)を有する.
  • は既に経路53または他のどこかにつくられるドメインを持っています.

  • 手順

    EC 2マシンにApacheをインストールする
    Tutorial: Install a LAMP web server on Amazon Linux 2
    $ sudo yum update -y
    $ sudo yum install -y httpd
    $ sudo systemctl start httpd
    $ sudo systemctl enable httpd
    $ sudo systemctl is-enabled httpd
    

    localhostを作成します.ブラウン管
    $ sudo yum install -y mod_ssl
    $ cd /etc/pki/tls/certs
    $ sudo ./make-dummy-cert localhost.crt
    
    それがドキュメンテーションでそう言うけれども、SSLCertificateKeyFile /etc/pki/tls/private/localhost.keyをコメントしないでください.それ以外の場合、Apacheを実行しているときにエラーが発生します.
    私は実際にこのlocalhostかどうかわからない.CRTも必要です.

    Certbotのインストールと実行
    $ sudo wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/
    $ sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-*.rpm
    $ sudo yum-config-manager --enable epel*
    
    次の行を/etc/httpd/conf/httpd.confに追加し、Listen 80の後に次の行を挿入します.
    <VirtualHost *:80>
        DocumentRoot "/var/www/html"
        ServerName "example.com"
        ServerAlias "www.example.com"
    </VirtualHost>
    
    Apacheを再起動し、certbotをインストールして実行します.
    $ sudo systemctl restart httpd
    $ sudo yum install -y certbot python2-certbot-apache
    $ sudo certbot
    
    条件に同意する.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Please read the Terms of Service at
    https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
    agree in order to register with the ACME server at
    https://acme-v02.api.letsencrypt.org/directory
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    (A)gree/(C)ancel: A
    
    アクティブにするドメイン名を選択します.
    Which names would you like to activate HTTPS for?
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    1: example.com
    2: www.example.com
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Select the appropriate numbers separated by commas and/or spaces, or leave input
    blank to select all options shown (Enter 'c' to cancel):
    
    この後、質問のカップルに答え、あなたがすべきである!
    Congratulations! You have successfully enabled https://example.com and
    https://www.example.com
    
    You should test your configuration at:
    https://www.ssllabs.com/ssltest/analyze.html?d=example.com
    https://www.ssllabs.com/ssltest/analyze.html?d=www.example.com
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    
    IMPORTANT NOTES:
     - Congratulations! Your certificate and chain have been saved at:
       /etc/letsencrypt/live/certbot.oneeyedman.net/fullchain.pem
       Your key file has been saved at:
       /etc/letsencrypt/live/certbot.oneeyedman.net/privkey.pem
       Your cert will expire on 2019-08-01. To obtain a new or tweaked
       version of this certificate in the future, simply run certbot again
       with the "certonly" option. To non-interactively renew *all* of
       your certificates, run "certbot renew"
     - Your account credentials have been saved in your Certbot
       configuration directory at /etc/letsencrypt. You should make a
       secure backup of this folder now. This configuration directory will
       also contain certificates and private keys obtained by Certbot so
       making regular backups of this folder is ideal.
    
    /etc/letsencrypt/live/certbot.oneeyedman.netであなたの証明書、秘密鍵、およびチェーンを見ることができます.これらをAmazon証明書マネージャにインポートし、エラスティックロードバランサーに使用できます.

    ピーエス
  • など、sudo yum installなどのChertbotをインストールする他の方法があります.私はAWSのdocsに従っています.
  • ですが、curlを使用する場合は、Amazon Linux 2の要件と一致するように設定を設定する必要があります.