summaryrefslogtreecommitdiffstats
path: root/roles/reverseproxy/templates/Caddyfile.j2
blob: 65544de68fad2bc6e75c767f597b139ae560dd68 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#
# {{ ansible_managed }}
#
saulnier.im {
    file_server
    header /.well-known/matrix/server {
        Content-Type application/json
    }
    header /.well-known/matrix/client {
        Access-Control-Allow-Origin *
        Content-Type application/json
    }
    header {
        Strict-Transport-Security "max-age=31536000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        X-Frame-Options "SAMEORIGIN"
        Referrer-Policy "no-referrer"
        -server
        -x-powered-by
    }

    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301

    reverse_proxy /_matrix/* http://localhost:9061 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        max_fails 60
    }
    respond /.well-known/matrix/server 200 {
        body "{ \"m.server\": \"matrix.saulnier.im:8448\" }"
        close
    }
    respond /.well-known/matrix/client 200 {
        body "{\"m.homeserver\": {\"base_url\": \"https://saulnier.im\"},\"m.identity_server\": {\"base_url\": \"https://saulnier.im\"}}"
        close
    }

    root * /media/nfs2
    php_fastcgi * localhost:18000 {
        root /media/nfs2
        env modHeadersAvailable true
        lb_policy first
        # Enable Retries by this setting:
        lb_try_duration 2s
        lb_try_interval 2s
    }

    @forbidden {
        path /.htaccess
        path /data/*
        path /config/*
        path /db_structure
        path /.xml
        path /README
        path /3rdparty/*
        path /lib/*
        path /templates/*
        path /occ
        path /console.php
    }
    respond @forbidden 404
}

{% for item in urlfiles %}
{{ item }} {
    file_server
    header {
        Strict-Transport-Security "max-age=31536000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        X-Frame-Options "SAMEORIGIN"
        Referrer-Policy "no-referrer"
        -server
        -x-powered-by
    }
    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301

    root * /media/nfs2
    php_fastcgi * localhost:18000 {
        root /media/nfs2
        env modHeadersAvailable true
        lb_policy first
        # Enable Retries by this setting:
        lb_try_duration 2s
        lb_try_interval 2s
    }

    @forbidden {
        path /.htaccess
        path /data/*
        path /config/*
        path /db_structure
        path /.xml
        path /README
        path /3rdparty/*
        path /lib/*
        path /templates/*
        path /occ
        path /console.php
    }
    respond @forbidden 404
}
{% endfor %}

l.saulnier.im {
    file_server
    header {
        Strict-Transport-Security "max-age=15552000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        -server
    }
    rewrite * /index.php?q={query}

    root * /media/nfs1/l.saulnier.im
    php_fastcgi * localhost:18001 {
        root /media/nfs1/l.saulnier.im
        env modHeadersAvailable true
        lb_policy first
        # Enable Retries by this setting:
        lb_try_duration 2s
        lb_try_interval 2s
    }
}



casperlefantom.net {
    file_server
    header {
        Strict-Transport-Security "max-age=15552000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        -server
    }
    header /feed/atom Content-Type text/xml
    header /.well-known/host-meta.json Access-Control-Allow-Origin *
    header /.well-known/host-meta {
        Access-Control-Allow-Origin *
        Content-Type application/xrd+xml
    }
    header /.well-known/matrix/server Content-Type application/json

    reverse_proxy /_matrix/* http://localhost:9061 {
        header_up Host {host}
        header_up X-Real-IP {remote}
        max_fails 60
    }
    root * /var/lib/caddy/casperlefantom.net
}

{% for item in urlchat %}
{{ item }} {
    file_server
    header {
        Strict-Transport-Security "max-age=15552000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        Content-Security-Policy "frame-ancestors 'self'; font-src 'self'; manifest-src https://{{ item }}/manifest.json; script-src 'sha256-+Iyb5umCXxHANCJZrJyKCaGg0iRVCR2OH+gTpZzObNs=' https://{{ item }}/dist/libsignal-protocol.min.js https://{{ item }}/dist/emojis.js https://{{ item }}/dist/converse.min.js https://{{ item }}/dist/locales/fr-LC_MESSAGES-converse-po.js https://{{ item }}/dist/locales/dayjs/fr-js.js"
        -server
    }
    handle_path /http-bind/* {
	    rewrite * /bosh
	    reverse_proxy http://localhost:9064 http://localhost:9066 {
            lb_policy first
            # Enable Retries by this setting:
            lb_try_duration 2s
            lb_try_interval 2s
	    }
    }
    handle_path /websocket/* {
	    rewrite * /ws
	    reverse_proxy ws://localhost:9065 ws://localhost:9067 {
            lb_policy first
            # Enable Retries by this setting:
            lb_try_duration 2s
            lb_try_interval 2s
        }
    }
    root * /var/lib/caddy/chat.casperlefantom.net
}
{% endfor %}

{% for item in urldl %}
{{ item }} {
    file_server browse
    @configfiles {
        path *.spec
        path *.cfg
        path *.conf
        path *.repo
        path *-CHECKSUM
    }
    header {
        Strict-Transport-Security "max-age=15552000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        Access-Control-Allow-Origin *
        -server
    }
    header @configfiles Content-Type "text/plain; charset=utf-8"
    header /pub/ssl/crt-crl.der {
        Content-Type application/pkix-crl
        Expires "Tue, 11 Feb 2025 1:37:02 GMT"
    }
    root * /media/nfs1/dl.casperlefantom.net
}
{% endfor %}

{% for item in urlmirror2 %}
{{ item }} {
    file_server browse
    header {
        Strict-Transport-Security "max-age=15552000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        -server
    }
    root * /media/nfs1/mirror-2.casperlefantom.net
}
{% endfor %}

{% for item in urlcirrus %}
{{ item }} {
    file_server
    header {
        Strict-Transport-Security "max-age=31536000"
        X-XSS-Protection "0"
        X-Content-Type-Options "nosniff"
        X-Download-Options "noopen"
        X-Permitted-Cross-Domain-Policies "none"
        X-Frame-Options "SAMEORIGIN"
        Referrer-Policy "no-referrer"
        -server
        -x-powered-by
    }
    root * /media/nfs2

    redir /.well-known/carddav /remote.php/dav 301
    redir /.well-known/caldav /remote.php/dav 301

    php_fastcgi * localhost:18000 {
        root /media/nfs2
        env modHeadersAvailable true
        lb_policy first
        # Enable Retries by this setting:
        lb_try_duration 2s
        lb_try_interval 2s
    }

    @forbidden {
        path /.htaccess
        path /data/*
        path /config/*
        path /db_structure
        path /.xml
        path /README
        path /3rdparty/*
        path /lib/*
        path /templates/*
        path /occ
        path /console.php
    }
    respond @forbidden 404
}
{% endfor %}



{% if domainhttps is defined %}
{% for item in domainhttps %}
{{ item }} {
    file_server
    root * /var/lib/caddy/default
}
{% endfor %}
{% endif %}

{% if publicstatic is defined %}
{% for item in publicstatic %}
{{ item }} {
    file_server
    root * /var/lib/caddy/{{ item }}
}
{% endfor %}
{% endif %}

{% if publicredir is defined %}
{% for item in publicredir %}
{{ item }} {
    redir https://{{ redirection }}{uri}
}
{% endfor %}
{% endif %}