Skip to content

Commit 21647d8

Browse files
committed
Switch to Caddy for local routing
1 parent 545deea commit 21647d8

File tree

4 files changed

+90
-8
lines changed

4 files changed

+90
-8
lines changed

bin/trust

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
cd "$(dirname "$0")/../"
4+
5+
./bin/check_for_updates
6+
7+
docker compose cp router:/data/caddy/pki/authorities/local/root.crt ./router/root.crt
8+
9+
case "$(uname -sr)" in
10+
Darwin*)
11+
echo 'Installing root certificate for macOS...'
12+
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ./router/root.crt
13+
;;
14+
15+
*)
16+
echo 'Cannot automatically install root certificate for your OS. Please install it manually. The certificate is located at $(realpath ./router/root.crt)'
17+
;;
18+
esac

docker-compose.yml

+19-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ volumes:
77
driver: local
88
typesense:
99
driver: local
10+
caddy_data:
11+
driver: local
1012

1113
services:
1214
# Databases
@@ -49,10 +51,24 @@ services:
4951
# Web server, routing /api and / to server, client respectively
5052
router:
5153
build: ./router
52-
depends_on: [web, api, minio, mailcatcher]
54+
command: [caddy, run, --watch, --config, /etc/caddy/Caddyfile]
55+
develop:
56+
watch:
57+
- action: sync
58+
path: ./router/Caddyfile
59+
target: /etc/caddy/Caddyfile
60+
ports:
61+
- target: 80
62+
published: 7580
63+
protocol: tcp
64+
- target: 443
65+
published: 7543
66+
protocol: tcp
67+
- target: 443
68+
published: 7543
69+
protocol: udp
5370
volumes:
54-
- uploads:/srv/www/uploads/system
55-
ports: ["42069:80"]
71+
- caddy_data:/data
5672

5773
# Application
5874
api: &rails

router/Caddyfile

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
debug
3+
local_certs
4+
auto_https disable_redirects
5+
}
6+
7+
(tls) {
8+
tls internal {
9+
on_demand
10+
}
11+
}
12+
13+
(log) {
14+
log {
15+
output stdout
16+
format console
17+
}
18+
}
19+
20+
(api) {
21+
handle /api/* {
22+
request_body {
23+
max_size 100MB
24+
}
25+
encode zstd gzip
26+
reverse_proxy http://api
27+
}
28+
}
29+
30+
media.kitsu.dev {
31+
import tls
32+
reverse_proxy http://minio:9000
33+
}
34+
35+
admin.media.kitsu.dev {
36+
import tls
37+
reverse_proxy http://minio:9001
38+
}
39+
40+
mail.kitsu.dev {
41+
import tls
42+
reverse_proxy http://mailcatcher:1080
43+
}
44+
45+
kitsu.dev, http://localhost {
46+
import tls
47+
import api
48+
reverse_proxy http://client
49+
}

router/Dockerfile

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
FROM nginx:1.9
2-
MAINTAINER Kitsu, Inc.
1+
FROM caddy:latest
32

4-
RUN rm /etc/nginx/conf.d/default.conf
5-
COPY ./nginx.conf /etc/nginx/conf.d/kitsu.conf
6-
COPY ./*.include.conf /etc/nginx/
3+
COPY private.pem /etc/caddy/private.pem
4+
COPY public.pem /etc/caddy/public.pem
5+
COPY Caddyfile /etc/caddy/Caddyfile

0 commit comments

Comments
 (0)