aboutsummaryrefslogtreecommitdiff
path: root/docs/caddy/monolith/CaddyFile
blob: cd93f9e106c612818d6a6dba3dfbfd578d8d7a02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
    # debug
    admin off
    email example@example.com
    default_sni example.com
    # Debug endpoint
    # acme_ca https://acme-staging-v02.api.letsencrypt.org/directory	
}

#######################################################################
#   Snippets
#______________________________________________________________________

(handle_errors_maintenance) {
	handle_errors {
		@maintenance expression {http.error.status_code} == 502
		rewrite @maintenance maintenance.html
		root * "/path/to/service/pages"
		file_server
	}
}

(matrix-well-known-header) {
    # Headers
    header Access-Control-Allow-Origin "*"
    header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS"
    header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization"
    header Content-Type "application/json"
}

#######################################################################

example.com {

	# ...

	handle /.well-known/matrix/server {
		import matrix-well-known-header
		respond `{ "m.server": "matrix.example.com:443" }` 200
	}
	
	handle /.well-known/matrix/client {
		import matrix-well-known-header
		respond `{ "m.homeserver": { "base_url": "https://matrix.example.com" } }` 200
	}

	import handle_errors_maintenance
}

example.com:8448 {
	# server<->server HTTPS traffic
    reverse_proxy http://dendrite-host:8008
}

matrix.example.com {

	handle /_matrix/* {
		# client<->server HTTPS traffic
		reverse_proxy  http://dendrite-host:8008
	}

	handle_path /* {
		# Client webapp (Element SPA or ...)
		file_server {
			root /path/to/www/example.com/matrix-web-client/
		}	
	}
}