Django でビルドされた Web アプリがあり、コマンド " docker-compose up
" を使用して Docker としてデプロイされるとします。これで、Web アプリをデプロイして実行することができました。
18b01238718d app_test:latest "/app/entrypoints/ap…" 5 minutes ago Up 5 minutes (healthy) 8001/tcp, 0.0.0.0:8002->8002/tcp test_api
2b8f3b48d1e4 app_test:latest "/app/entrypoints/cr…" 5 minutes ago Up 5 minutes 8001-8002/tcp test_cron
a2413139919e app_test:latest "/app/entrypoints/ad…" 5 minutes ago Up 5 minutes (healthy) 0.0.0.0:8001->8001/tcp, 8002/tcp test_admin
4e76dbee107d postgres:12.5 "docker-entrypoint.s…" 5 minutes ago Up 5 minutes 5432/tcp test_db
IP:8001 を使用してサイトにアクセスできます
IP:80 としてサイトにアクセスできるようにするには、どうすれば caddy を使用できますか?
私がやった事:
install Caddy and verified it is running.
systemctl status caddy
● caddy.service - Caddy
Loaded: loaded (/usr/lib/systemd/system/caddy.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2021-04-03 13:54:11 UTC; 3s ago
mydomain:80 にアクセスすると、
Web サーバーは動作しています。今、あなたのためにそれを働かせてください。
Caddy is ready to serve your site over HTTPS:
Point your domain's A/AAAA DNS records at this machine.
Upload your site's files to /var/www/html.
Edit your Caddyfile at /etc/caddy/Caddyfile:
Replace :80 with your domain name
Change the site root to /var/www/html
Reload the configuration: systemctl reload caddy
Visit your site!
次に、 /etc/caddy/Caddyfile: を次のように編集しました
mydomain.com
# Set this path to your site's directory.
root * /usr/share/caddy (I believe this should point to my volume of my docker web app. but I don't know how we can do that. any help is appreciated. )
# 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
www.mydonmain.com {
reverse_proxy 127.0.0.1:8001
}
api.mydonmain.com {
reverse_proxy 127.0.0.1:8002
}
root * /usr/share/caddy
(これは自分の docker Web アプリのボリュームを指すはずですが、Web アプリが docker-compose ボリュームで「実行」されていることを考えると、それを行う方法がわかりません。助けていただければ幸いです。)
私が得たものはどこにありますか systemctl status caddy
Apr 03 15:05:34 web-centos caddy[54954]: {"level":"info","ts":1617462334.6150506,"logger":"tls.issuance.acme","msg":"done waiting on internal rate limiter","identifiers":["mydomain.com"]}
Apr 03 15:05:34 web-centos caddy[54954]: {"level":"info","ts":1617462334.8799675,"logger":"tls.issuance.acme.acme_client","msg":"trying to solve challenge","identifier":"mydomain.com","challenge_type":"tl>
Apr 03 15:05:35 web-centos caddy[54954]: {"level":"info","ts":1617462335.2093322,"logger":"tls","msg":"served key authentication certificate","server_name":"mydomain.com","challenge":"tls-alpn-01","remote>
Apr 03 15:05:35 web-centos caddy[54954]: {"level":"info","ts":1617462335.286796,"logger":"tls","msg":"served key authentication certificate","server_name":"mydomain.com","challenge":"tls-alpn-01","remote">
Apr 03 15:05:35 web-centos caddy[54954]: {"level":"info","ts":1617462335.3579297,"logger":"tls","msg":"served key authentication certificate","server_name":"mydomain.com","challenge":"tls-alpn-01","remote>
Apr 03 15:05:35 web-centos caddy[54954]: {"level":"info","ts":1617462335.4760425,"logger":"tls","msg":"served key authentication certificate","server_name":"mydomain.com","challenge":"tls-alpn-01","remote>