Skip to content

Commit bb16577

Browse files
committed
Re-route HOSTNAME to www.HOSTNAME in prod
- Re-add staging Caddyfile
1 parent df44583 commit bb16577

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Caddyfile

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{$CADDY_HOST} {
1+
www.{$CADDY_HOST} {
22
tls {$CADDY_TLS_EMAIL}
33
gzip
44
root /var/www/nerd_herder
@@ -28,3 +28,7 @@
2828
without /proxy
2929
}
3030
}
31+
32+
{$CADDY_HOST} {
33+
redir https://www.{$CADDY_HOST}{uri}
34+
}

Caddyfile.staging

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{$CADDY_HOST} {
2+
tls {$CADDY_TLS_EMAIL}
3+
gzip
4+
root /var/www/nerd_herder
5+
6+
redir 302 {
7+
# Caddy is dumb and has no way of redirecting only the index without this if statment.
8+
if {path} is /
9+
/ /app/
10+
}
11+
12+
rewrite /app {
13+
to {path} {path}/ /
14+
}
15+
16+
rewrite /favicon {
17+
to {path}
18+
}
19+
20+
# First attempt to load the file (via {path}), if that fails re-write to the proxy URL
21+
rewrite {
22+
to {path} /proxy/{uri}
23+
}
24+
25+
# Proxy to nerd_herder service via /proxy, but drop the /proxy prefix
26+
proxy /proxy nerd_herder:8080 {
27+
transparent
28+
without /proxy
29+
}
30+
}

docker-compose.staging.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ services:
6161
- nerd_herder
6262
volumes:
6363
- './.docker-data/caddy:/root/.caddy'
64-
- './Caddyfile:/etc/Caddyfile'
64+
- './Caddyfile.staging:/etc/Caddyfile'
6565
ports:
6666
- '8080:8080'

0 commit comments

Comments
 (0)