LoginSignup
5
3

More than 3 years have passed since last update.

DockerでCaddyを試す

Posted at

はじめに

爆速! AWS EC2(Amazon Linux)環境でHTTPS環境を建てる方法 (Caddy)をみて面白そうだなって思った。試したいけど、環境構築は面倒だなってことで、Dockerで試しに動かしてみることにした。

試しに動かしてみる

# ポートは片方だけでも動きます
$ docker run --rm -it -p 80:80 -p 443:443 caddy

接続先は、http://localhostでした。

image.png

中身が見たい

$ docker run --rm -it -p 80:80 -p 443:443 caddy /bin/ash

設定ファイル

/etc/caddy内にCaddyfileがあります。

/etc/caddy/Caddyfile
# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace the line below with your
# domain name.
:80

# Set this path to your site's directory.
root * /usr/share/caddy

# Enable the static file server.
file_server

# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080

# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile

おわりに

Dockerfileとかを試したい場合は、以下が参考になると思います。

caddy
Go製WebサーバーCaddy触ってみた

5
3
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
5
3