Skip to content

Commit 709f257

Browse files
Upgrade caddy (#828)
Co-authored-by: Dax McDonald` <31839142+daxmc99@users.noreply.github.com>
1 parent 5ba2840 commit 709f257

File tree

5 files changed

+48
-27
lines changed

5 files changed

+48
-27
lines changed

caddy/builtins/http.Caddyfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@
44

55
:80
66

7-
reverse_proxy {$SRC_FRONTEND_ADDRESSES}
7+
# Add the reverse proxies IPs (or IP CIDR ranges) to the trusted_proxies list.
8+
# More information in https://caddyserver.com/docs/caddyfile/directives/reverse_proxy
9+
reverse_proxy {
10+
to {$SRC_FRONTEND_ADDRESSES}
11+
trusted_proxies 0.0.0.0/0
12+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Serves Sourcegraph over HTTPS, using a custom SSL certificate/key pair
1+
# Serves Sourcegraph over HTTPS, using a custom SSL certificate/key pair
22
# that's bind mounted from the host to /sourcegraph.pem and /sourcegraph.key.
33
#
44
# Caddyfile documentation: https://caddyserver.com/docs/caddyfile
@@ -7,10 +7,15 @@
77

88
# Redirects all HTTP traffic to HTTPS (using custom SSL certificates disables the automatic HTTPS feature of Caddy, see https://caddyserver.com/docs/automatic-https)
99
@http {
10-
protocol http
10+
protocol http
1111
}
1212
redir @http https://{host}{uri}
1313

1414
tls /sourcegraph.pem /sourcegraph.key
1515

16-
reverse_proxy {$SRC_FRONTEND_ADDRESSES}
16+
# Add the reverse proxies IPs (or IP CIDR ranges) to the trusted_proxies list.
17+
# More information in https://caddyserver.com/docs/caddyfile/directives/reverse_proxy
18+
reverse_proxy {
19+
to {$SRC_FRONTEND_ADDRESSES}
20+
trusted_proxies 0.0.0.0/0
21+
}
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
# Serves Sourcegraph over HTTPS, using Caddy's automatic HTTPS certificate feature:
22
# https://caddyserver.com/docs/automatic-https
33
#
4-
# 🚨 Warning: If your DNS and Caddy configuration aren't properly configured (as
5-
# specified in https://caddyserver.com/docs/automatic-https), you can
6-
# run into Let's Encrypt rate limits which can block your certificates
7-
# for up to a week.
8-
# It's strongly recommened that you use the staging Caddyfile
4+
# 🚨 Warning: If your DNS and Caddy configuration aren't properly configured (as
5+
# specified in https://caddyserver.com/docs/automatic-https), you can
6+
# run into Let's Encrypt rate limits which can block your certificates
7+
# for up to a week.
8+
# It's strongly recommened that you use the staging Caddyfile
99
# (https.lets-encrypt-staging.Caddyfile) to test your
10-
# configuration before switching to this production one.
10+
# configuration before switching to this production one.
1111
#
1212
# Caddyfile documentation: https://caddyserver.com/docs/caddyfile
1313
#
14-
1514
{
16-
email {$SRC_ACME_EMAIL}
15+
email {$SRC_ACME_EMAIL}
1716
}
1817

1918
{$SRC_SITE_ADDRESS}
2019

21-
reverse_proxy {$SRC_FRONTEND_ADDRESSES}
20+
# Add the reverse proxies IPs (or IP CIDR ranges) to the trusted_proxies list.
21+
# More information in https://caddyserver.com/docs/caddyfile/directives/reverse_proxy
22+
reverse_proxy {
23+
to {$SRC_FRONTEND_ADDRESSES}
24+
trusted_proxies 0.0.0.0/0
25+
}
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
# Serves Sourcegraph over HTTPS, using Caddy's automatic HTTPS certificate feature:
22
# https://caddyserver.com/docs/automatic-https
3-
#
4-
# Note: This configuration uses Let's Encrypt's staging environment. This will
5-
# allow you to ensure that everything is correctly configured (with a reduced
3+
#
4+
# Note: This configuration uses Let's Encrypt's staging environment. This will
5+
# allow you to ensure that everything is correctly configured (with a reduced
66
# chance of running into rate limit issues). Note that using this configuration
77
# issues a fake certificate (for testing purposes) instead of a trusted one.
88
#
9-
# 🚨 Warning: If your DNS and Caddy configuration aren't properly configured (as
10-
# specified in https://caddyserver.com/docs/automatic-https), you can
11-
# run into Let's Encrypt rate limits which can block your certificates
12-
# for up to a week.
9+
# 🚨 Warning: If your DNS and Caddy configuration aren't properly configured (as
10+
# specified in https://caddyserver.com/docs/automatic-https), you can
11+
# run into Let's Encrypt rate limits which can block your certificates
12+
# for up to a week.
1313
# It's strongly recommened that you use this Caddyfile to test your
14-
# configuration before switching to the production one.
14+
# configuration before switching to the production one.
1515
#
1616
# Caddyfile documentation: https://caddyserver.com/docs/caddyfile
1717
#
18-
1918
{
20-
# Use Let's Encrypt's staging environment
21-
acme_ca "https://acme-staging-v02.api.letsencrypt.org/directory"
22-
email {$SRC_ACME_EMAIL}
19+
# Use Let's Encrypt's staging environment
20+
acme_ca "https://acme-staging-v02.api.letsencrypt.org/directory"
21+
email {$SRC_ACME_EMAIL}
2322
}
2423

2524
{$SRC_SITE_ADDRESS}
2625

27-
reverse_proxy {$SRC_FRONTEND_ADDRESSES}
26+
# Add the reverse proxies IPs (or IP CIDR ranges) to the trusted_proxies list.
27+
# More information in https://caddyserver.com/docs/caddyfile/directives/reverse_proxy
28+
reverse_proxy {
29+
to {$SRC_FRONTEND_ADDRESSES}
30+
trusted_proxies 0.0.0.0/0
31+
}

docker-compose/docker-compose.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ services:
7070
# https://caddyserver.com/docs/caddyfile
7171
caddy:
7272
container_name: caddy
73-
image: 'index.docker.io/caddy:2.4.6-alpine@sha256:b5a59725783bab0d65803f87028c68dd6611ca6184040bd98b18797cbe26bdd9'
73+
image: 'index.docker.io/caddy:2.5.1-alpine@sha256:6e62b63d4d7a4826f9e93c904a0e5b886a8bea2234b6569e300924282a2e8e6c'
7474
cpus: 4
7575
mem_limit: '4g'
7676
environment:
@@ -85,6 +85,9 @@ services:
8585
volumes:
8686
- 'caddy:/caddy-storage'
8787
#
88+
# IMPORTANT: if a customer uses a reverse proxy in front of Caddy
89+
# the configuration files below must be updated to include trusted_proxies
90+
#
8891
# Comment out the following line when using HTTPS with either Let's Encrypt or custom certificates
8992
- '../caddy/builtins/http.Caddyfile:/etc/caddy/Caddyfile'
9093
#

0 commit comments

Comments
 (0)