aboutsummaryrefslogtreecommitdiff
path: root/infra/Caddyfile
blob: 424e12980b66c6419f7b7977d92dcb8ae6aadf8c (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Copyright (C) 2026 Doan Luu Duc Tai <doan@luuduct.ai>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

{
    http_port {{HTTP_PORT}}
    https_port {{HTTPS_PORT}}
}

(https_security) {
    header >Strict-Transport-Security "max-age=31536000"
}

https://{{BASE_DOMAIN}}:{{HTTPS_PORT}} {
	import https_security
	handle /.well-known/openpgpkey/* {
		root * /srv
		header Content-Type application/octet-stream
		file_server
	}

	handle {
		redir {{SITE_ORIGIN}}{uri} permanent
	}
}

https://www.{{BASE_DOMAIN}}:{{HTTPS_PORT}} {
	import https_security
	redir {{SITE_ORIGIN}}{uri} permanent
}

https://{{SITE_HOST}}:{{HTTPS_PORT}} {
	import https_security
	root * /srv
	file_server

	redir /git /git/

	handle /cgit* {
		reverse_proxy {{CGIT_UPSTREAM}}
	}

	handle /git/* {
		reverse_proxy {{CGIT_UPSTREAM}}
	}
}

https://{{WKD_HOST}}:{{HTTPS_PORT}} {
	import https_security
	handle /.well-known/openpgpkey/* {
		root * /srv
		header Content-Type application/octet-stream
		file_server
	}
}

https://{{GIT_HOST}}:{{HTTPS_PORT}} {
	import https_security
	redir /{path}.git /{path} permanent

	reverse_proxy {{CGIT_UPSTREAM}}
}

https://{{SEARCH_HOST}}:{{HTTPS_PORT}} {
	import https_security
	reverse_proxy {{SEARXNG_UPSTREAM}}
}

https://www.{{SITE_HOST}}:{{HTTPS_PORT}} {
	import https_security
    redir {{SITE_ORIGIN}}{uri} permanent
}

https://www.{{GIT_HOST}}:{{HTTPS_PORT}} {
	import https_security
    redir {{GIT_ORIGIN}}{uri} permanent
}

https://www.{{SEARCH_HOST}}:{{HTTPS_PORT}} {
	import https_security
    redir {{SEARCH_ORIGIN}}{uri} permanent
}

https://www.{{WKD_HOST}}:{{HTTPS_PORT}} {
    import https_security
    redir {{WKD_ORIGIN}}{uri} permanent
}