10
1

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 1 year has passed since last update.

[小ネタ] Caddy でローカルのみ通用するHTTPSサイトをワンライナーで立てる

Last updated at Posted at 2023-01-20

たとえば下記コマンドを実行し、 https://oreore-https-site.localhost にアクセスすると http://127.0.0.1:3000 に繋ぐリバースプロキシを一発で立てることができます。

$ caddy reverse-proxy --from oreore-https-site.localhost --to 127.0.0.1:3000

# (追加のツールのインストールやパスワードを求められるかも)

もちろんローカル以外では通用しないなんちゃってHTTPSサイトですが、HTTPSでしか使えないブラウザの機能を解放する場合など即席でHTTPSが必要なケースには便利だと思います。

(おまけ) Caddyのインストール方法

# Mac
$ brew install caddy
# Windows
$ scoop install caddy

(おまけ) *.localhost ドメインとは?

.localhostは、ループバックを示すことを目的としたトップレベルドメイン(TLD)である。

たとえば、 http://localhost:3000 のかわりに http://any-string-goes-here.localhost:3000 というURLを使ってもローカルホストに繋がります。1

  1. Google Chromeだとローカルホストにつながったのですが、curlだと繋がりませんでした。ユーザーエージェントごとに .localhost のサポート状況は違うようです。もちろん hosts に書いてしまうのも手です。

10
1
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
10
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?