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 5 years have passed since last update.

(クソ記事) localhost上でHTTPSなnginxコンテナを動作させ、/etc/hostsで名前解決してGmail APIのOAuth2を通す

Posted at

TL;DR

できます。
できました。

必要なもの

  • MacOS
  • mkcert (brew install)
  • docker for Mac
    • nginx:latest
  • /etc/hostsに関する知識
  • dockerに関する知識

モチベ

  • わざわざドメイン取ったりDNS管理したりする必要があり、ただの静的HTMLをHTTPS公開したいだけなのに無料で出来ない。馬鹿馬鹿しい。
  • じゃあlocalhostに対して、公開ドメイン名をhostsでmapしてブラウザ騙せばいいよね
  • 実際に やってみた
  • できた
  • なおOAuth Consent Screenとかドメイン所有権確認とかは、ちゃんとDNS触ったりしたので、実は認証取るのに完全無料じゃない可能性はある。

やりかた

  1. コンテンツを作る。( index.html )
  2. nginx:latest をpullしてくる。
  3. mkcert で localhost と 対象のドメイン名に対応する証明書を生成し、自分のMacにinstallする。
  4. nginxを TCP/443 でLISTENさせ、証明書とTLS関連設定を持ったssl.confをCOPYし、ビルド
  5. コンテンツのディレクトリをmountさせ、docker run
  6. https://www.example.com/path/to/file.html みたいにアクセスしてみる
  7. できた

続かない

とりあえず「できた」ことだけメモっとく。

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?