memo - tetsuyaf1100/hello-world GitHub Wiki

20210101

  • install nginx to ec2 instance
sudo amazon-linux-extras install nginx1
  • selfcert
cd
openssl genrsa 2048 > server.key
openssl req -new -key server.key > server.csr
openssl x509 -days 365 -req -signkey server.key < server.csr > server.crt
mv server.* /etc/nginx/conf.d/
  • setting nginx
vim /etc/nginx/conf.d/ssl_redirect.conf


server {
    listen       443 ssl;
    server_name  localhost;
    ssl_certificate      /etc/nginx/conf.d/server.crt;
    ssl_certificate_key  /etc/nginx/conf.d/server.key;
    location / {
        proxy_pass http://127.0.0.1:3000;
    }
}

20201229

EC2インスタンス作成

certbot install, get cert

sudo amazon-linux-extras install epel
yum install certbot

certbot certonly --manual --domain fukuda.tk --email [email protected] --agree-tos --manual-public-ip-logging-ok --preferred-challenges dns

freenom.com でTXTレコード編集

dig -t txt _acme-challenge.fukuda.tk

httpd

yum install httpd mod_ssl
vim /etc/httpd/conf.d/ssl.conf

ln -s /etc/letsencrypt/live live

vim /etc/letsencrypt/letsencrypt-renew.sh
chmod 700 /etc/letsencrypt/letsencrypt-renew.sh

crontab -e
0 3 * * * /etc/letsencrypt/letsencrypt-renew.sh


systemctl start httpd
systemctl enable httpd

terrafrom

terraformコマンドは本来同じフォルダ階層内にあるtfファイルでしか読み込めないが、パス指定して実行するとほかの場所にあるtfファイルに対して実行できるようになった。

特定の場所のみ実行したい場合、-chdirオプション