0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

acme.shを使って無料でTLS(SSL)証明書を取得する

Last updated at Posted at 2021-11-13

概要

acme.shを使うとLet's Encryptで簡単に証明書が取得できる。今回はローカル環境で証明書を発行してみる。

インストール

emailの部分は適宜自分のものに変更する。

curl https://get.acme.sh | sh -s email=my@example.com
source ~/.zshrc

アカウント発行

acme.sh --register-account -m my@example.com

証明書発行

ngrokのUIでドメインの設定を行う

ngrokで該当ドメインにきたトラフィックをローカルのマシンにトンネルする設定を作る。左のメニューのDomainsから新規ドメインを追加する。

下記のような設定になるようにする。

Screen Shot 2021-11-13 at 15.18.47.png

DNSのCNAMEを設定

ngrokで払い出された一時ドメイン(2abdgylzz.cname.jp.ngrok.io)を使っているDNSサーバでレコードを作成してCNAMEに割り当てる。

Route53であれば下記のようになる。

Screen Shot 2021-11-13 at 15.21.58.png

ngrokでポートフォワードを行う。

ngrokコマンドが入っていなければbrew install ngrokや、yay ngrokなどとして使っているOSのパッケージマネジャを使ってインストールしておく。

次にngrokのトンネルを開始する。

ngrok http --region=jp --hostname=ドメイン名 8081

ウェブサーバ

Let's encryptが通信してくるウェブサーバを起動する。

docker run -it \
	--rm \
	-d \
	-p 8081:80 \
	--name web \
	-v ~/適当なディレクトリ:/usr/share/nginx/html \
	nginx

acme.shで証明書発行

acme.sh --issue -d ドメイン名 -w ~/適当なディレクトリ

~/.acme.sh/ドメイン名に証明書が作成される。

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?