Skip to content

Commit c135b6f

Browse files
committed
switching to classic caddy service
1 parent 0b83585 commit c135b6f

File tree

5 files changed

+104
-63
lines changed

5 files changed

+104
-63
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@
1010
.env
1111
.envs-*
1212
# ignore the certs files automatically downloaded on docker-compose up
13-
resources/caddy/*
14-
!resources/caddy/README.md
13+
resources/caddy/data/*

README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ docker compose down
5050

5151
**4. Play**
5252

53-
Open [https://georchestra-127-0-1-1.traefik.me/](https://georchestra-127-0-1-1.traefik.me/) in your browser.
53+
Open [https://georchestra-127-0-1-1.traefik.me/](https://georchestra-127-0-1-1.traefik.me/) in your browser. Then:
54+
55+
* Accept the security warning.
56+
* Or solve the security warning by [following this step](#locally-trust-the-tls-certificate-for-georchestra).
5457

5558
To login, use these credentials:
5659
* `testuser` / `testuser`
@@ -68,18 +71,41 @@ Emails sent by the SDI (eg when users request a new password) will not be relaye
6871
These emails can be read on https://georchestra-127-0-1-1.traefik.me/webmail/ (with login `smtp` and password `smtp`).
6972

7073

74+
## Locally trust the TLS certificate for geOrchestra
75+
### On Linux
76+
77+
1. Download Caddy binary: `wget "https://caddyserver.com/api/download?os=linux&arch=amd64"`
78+
2. Make it executable: `chmod +x caddy`
79+
3. Trust the certificate using this command: `./caddy trust`.
80+
4. Open [https://georchestra-127-0-1-1.traefik.me/](https://georchestra-127-0-1-1.traefik.me/) in your browser.
81+
If that doesn't work, try to restart your browser.
82+
83+
### On Windows
84+
1. Download Caddy binary: https://caddyserver.com/download
85+
Click on Download button on the website.
86+
2. Open the Downloads folder using your file explorer and rename the file downloaded to `caddy`.
87+
3. Open the command prompt (cmd) and navigate to your Downloads folder.
88+
`cd "C:\Users\%USERNAME%\Downloads"`
89+
3. Trust the certificate using this command: `caddy trust`.
90+
4. Open [https://georchestra-127-0-1-1.traefik.me/](https://georchestra-127-0-1-1.traefik.me/) in your browser.
91+
If that doesn't work, try to restart your browser.
92+
7193
## About the domain name
7294

7395
The current FQDN `georchestra-127-0-1-1.traefik.me` resolves to 127.0.1.1, thanks to [traefik.me](https://traefik.me/) which provides wildcard DNS for any IP address.
7496

7597
To change it:
76-
* Rename the traefik service in the `docker-compose.override.yml` file to match the new domain
77-
* Modify the three `traefik.http.routers.*.rule` in the `docker-compose.override.yml` file
78-
* Update the FQDN variable in [.envs-common](.envs-common) file (hint: grep for `georchestra-127-0-1-1.traefik.me`)
79-
* Put a valid SSL certificate in the `resources/ssl` folder and declare it in the `resources/traefik-config.yml` file
98+
99+
1. Update the FQDN variable in [.envs-common](.envs-common) file (hint: grep for `georchestra-127-0-1-1.traefik.me`)
100+
2. Two options for the TLS/SSL certificate:
101+
* If your web server exposed to the internet (most likely it is), remove `tls internal` line in the file `resources/caddy/etc/Caddyfile`.
102+
* If it is not, put a valid TLS certificate and a private key in the `resources/ssl` folder and declare it in the file `resources/caddy/etc/Caddyfile`.
103+
3. Reload the docker composition: `docker compose up -d`
80104

81105
## Notes
82106

107+
Find the Caddy web server documentation here: https://caddyserver.com/docs/caddyfile/directives.
108+
83109
These docker-compose files describe:
84110
* which images / webapps will run,
85111
* how they are linked together,

docker-compose.override.yml

Lines changed: 15 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,26 @@ volumes:
99

1010
services:
1111
caddy:
12-
image: lucaslorentz/caddy-docker-proxy:2.8-alpine
13-
networks:
14-
- caddy
12+
image: caddy:2.8-alpine
1513
ports:
1614
- "80:80"
1715
- "443:443"
16+
- "127.0.0.1:2019:2019"
17+
environment:
18+
- CADDY_ADMIN=0.0.0.0:2019
1819
volumes:
19-
- /var/run/docker.sock:/var/run/docker.sock:ro
20-
- ./resources/caddy:/data/caddy
20+
- ./resources/ssl:/etc/certs:ro
21+
- ./resources/caddy/etc:/etc/caddy:ro
22+
- ./resources/caddy/data:/data/caddy
23+
- ./resources/static:/usr/share/caddy/static:ro
2124
restart: always
22-
23-
static:
24-
image: nginx:stable
25-
restart: unless-stopped
26-
networks:
27-
- caddy
28-
volumes:
29-
- ./resources/static:/usr/share/nginx/html:ro
30-
- /etc/localtime:/etc/localtime:ro
31-
labels:
32-
- "caddy=georchestra-127-0-1-1.traefik.me"
33-
- "caddy.tls=internal"
34-
- "caddy.handle=/public/*"
35-
- "caddy.handle.0_reverse_proxy={{upstreams 80}}"
36-
37-
proxy:
38-
networks:
39-
- caddy
40-
- default
41-
labels:
42-
- "caddy=georchestra-127-0-1-1.traefik.me"
43-
- "caddy.tls=internal"
44-
- "caddy.handle.reverse_proxy={{upstreams 8080}}"
45-
- "caddy.handle.0_header=Access-Control-Allow-Origin *"
46-
- "caddy.handle.1_header=Access-Control-Allow-Methods \"GET, POST, PUT, PATCH, DELETE, OPTIONS\""
47-
- "caddy.handle.2_header=Access-Control-Max-Age 1800"
48-
- "caddy.handle.3_header=Access-Control-Allow-Credentials: true"
49-
- "caddy.@trailingslash=path_regexp reg_static ^/(\\w+)$"
50-
- "caddy.redir=@trailingslash /{http.regexp.reg_static.1}/"
51-
52-
cas:
53-
networks:
54-
- caddy
55-
- default
56-
labels:
57-
- "caddy=georchestra-127-0-1-1.traefik.me"
58-
- "caddy.tls=internal"
59-
- "caddy.handle=/cas/*"
60-
- "caddy.handle.0_reverse_proxy={{upstreams 8080}}"
25+
healthcheck:
26+
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:2019/reverse_proxy/upstreams >/dev/null || exit 1"]
27+
interval: 30s
28+
timeout: 10s
29+
retries: 10
30+
env_file:
31+
- .envs-common
6132

6233
smtp:
6334
image: camptocamp/smtp-sink:latest
@@ -76,16 +47,8 @@ services:
7647
environment:
7748
- IMAP_HOSTNAME=courier-imap
7849
- SMTP_HOSTNAME=smtp-sink
79-
networks:
80-
- caddy
81-
- default
8250
volumes:
8351
- smtp_maildir:/home/smtp/Maildir/
84-
labels:
85-
- "caddy=georchestra-127-0-1-1.traefik.me"
86-
- "caddy.tls=internal"
87-
- "caddy.handle=/webmail/*"
88-
- "caddy.handle.0_reverse_proxy={{upstreams 80}}"
8952
restart: always
9053

9154
ssh:
@@ -95,6 +58,3 @@ services:
9558
volumes:
9659
- geoserver_geodata:/mnt/geoserver_geodata
9760
restart: always
98-
99-
networks:
100-
caddy:

resources/caddy/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
This repository is for the storage of caddy webserver.
1+
* `etc`: Configuration folder for Caddy web server. You will find the Caddyfile there.
2+
* `data`: This repository is for the storage of Caddy web server.

resources/caddy/etc/Caddyfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
(static_fileserver) {
2+
root * /usr/share/caddy/static
3+
file_server
4+
}
5+
6+
{$FQDN} {
7+
tls internal
8+
# For using a custom certificate:
9+
# tls /etc/certs/ca.pem /etc/certs/key.pem
10+
11+
@trailing-slash {
12+
path_regexp reg_static ^/(\w+)$
13+
}
14+
15+
@static-resources {
16+
path /favicon.ico
17+
path /crossdomain.xml
18+
path /robots.txt
19+
}
20+
21+
handle_errors {
22+
@5xx `{err.status_code} >= 500 && {err.status_code} < 600`
23+
handle @5xx {
24+
import static_fileserver
25+
rewrite * /errors/50x.html
26+
}
27+
}
28+
29+
handle @static-resources {
30+
import static_fileserver
31+
}
32+
33+
handle_path /public/* {
34+
import static_fileserver
35+
}
36+
37+
handle /cas/* {
38+
reverse_proxy cas:8080
39+
}
40+
41+
handle /webmail/* {
42+
reverse_proxy webmail:80
43+
}
44+
45+
handle {
46+
reverse_proxy proxy:8080
47+
header {
48+
Access-Control-Allow-Origin *
49+
Access-Control-Allow-Methods "GET, POST, PUT, PATCH, DELETE, OPTIONS"
50+
Access-Control-Max-Age 1800
51+
Access-Control-Allow-Credentials: true
52+
}
53+
redir @trailing-slash /{http.regexp.reg_static.1}/
54+
}
55+
}

0 commit comments

Comments
 (0)