summaryrefslogtreecommitdiff
path: root/frontends/etc/httpd.conf.tpl
blob: 376692f2a53114f917ca15172c4d9bf092553342 (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
<% our @prefixes = ('', 'www.', 'standby.'); -%>
# Plain HTTP for ACME and HTTPS redirect
<% for my $host (@$acme_hosts) {
     # Skip current server's hostname - handled by dedicated block below
     next if $host eq "$hostname.$domain";
     for my $prefix (@prefixes) { -%>
server "<%= $prefix.$host %>" {
  listen on * port 80
  log style forwarded
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
  }
  location * {
    block return 302 "https://$HTTP_HOST$REQUEST_URI"
  }
}
<% } } -%>

# Current server's FQDN (e.g. for mail server ACME cert requests)
server "<%= "$hostname.$domain" %>" {
  listen on * port 80
  log style forwarded 
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
  }
  location * {
    block return 302 "https://<%= "$hostname.$domain" %>"
  }
}

server "<%= "$hostname.$domain" %>" {
  listen on * port 8080
  log style forwarded 
  location * {
    root "/htdocs/buetow.org/self"
    directory auto index
  }
}

# f3s cluster fallback page on port 8080 when cluster is down
server "f3s.buetow.org" {
  listen on * port 8080
  log style forwarded
  location * {
    # Rewrite all requests to /index.html to show fallback page regardless of path
    request rewrite "/index.html"
    root "/htdocs/f3s_fallback"
  }
}

# Catch-all for any unmatched .f3s.buetow.org subdomain on port 8080
# Serves fallback page when k3s cluster is down
server "*.f3s.buetow.org" {
  listen on * port 8080
  log style forwarded
  location * {
    # Rewrite all requests to /index.html to show fallback page regardless of path
    request rewrite "/index.html"
    root "/htdocs/f3s_fallback"
  }
}

# Gemtexter hosts
<% for my $host (qw/foo.zone stats.foo.zone/) { for my $prefix (@prefixes) { -%>
server "<%= $prefix.$host %>" {
  listen on * port 8080
  log style forwarded 
  location "/.git*" {
    block return 302 "https://<%= $prefix.$host %>"
  }
  location * {
    <% if ($prefix eq 'www.') { -%>
    block return 302 "https://<%= $host %>$REQUEST_URI"
    <% } else { -%>
    root "/htdocs/gemtexter/<%= $host %>"
    directory auto index
    <% } -%>
  }
}
<% } } -%>

# Redirect to paul.buetow.org
<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>buetow.org" {
  listen on * port 8080
  log style forwarded 
  location * {
    block return 302 "https://paul.buetow.org$REQUEST_URI"
  }
}

# Redirect blog to foo.zone
server "<%= $prefix %>blog.buetow.org" {
  listen on * port 8080
  log style forwarded 
  location * {
    block return 302 "https://foo.zone$REQUEST_URI"
  }
}

server "<%= $prefix %>snonux.foo" {
  listen on * port 8080
  log style forwarded
  location * {
    <% if ($prefix eq 'www.') { -%>
    block return 302 "https://snonux.foo$REQUEST_URI"
    <% } else { -%>
    # Same fallback as f3s.buetow.org when static Pis are unreachable (via f3s_static_proxy chain)
    request rewrite "/index.html"
    root "/htdocs/f3s_fallback"
    <% } -%>
  }
}

server "<%= $prefix %>paul.buetow.org" {
  listen on * port 8080
  log style forwarded 
  location * {
    block return 302 "https://foo.zone/about$REQUEST_URI"
  }
}
<% } -%>

<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>dtail.dev" {
  listen on * port 8080
  log style forwarded 
  location * {
    block return 302 "https://codeberg.org/snonux/dtail"
  }
}
<% } -%>

# Irregular Ninja special hosts
<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>irregular.ninja" {
  listen on * port 8080
  log style forwarded 
  location * {
    root "/htdocs/irregular.ninja"
    directory auto index
  }
}
<% } -%>

<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>alt.irregular.ninja" {
  listen on * port 8080
  log style forwarded 
  location * {
    root "/htdocs/alt.irregular.ninja"
    directory auto index
  }
}
<% } -%>

# joern special host
<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>joern.buetow.org" {
  listen on * port 8080
  log style forwarded 
  location * {
    root "/htdocs/joern/"
    directory auto index
  }
}
<% } -%>

# Dory special host
<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>dory.buetow.org" {
  listen on * port 8080
  log style forwarded 
  location * {
    root "/htdocs/joern/dory.buetow.org"
    directory auto index
  }
}
<% } -%>

# ecat special host
<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>ecat.buetow.org" {
  listen on * port 8080
  log style forwarded 
  location * {
    root "/htdocs/joern/ecat.buetow.org"
    directory auto index
  }
}
<% } -%>

# gogios special host
<% for my $prefix (@prefixes) { -%>
server "<%= $prefix %>gogios.buetow.org" {
  listen on * port 8080
  log style forwarded
  location * {
    root "/htdocs/buetow.org/self/gogios"
    directory auto index
  }
}
<% } -%>

# f3s hosts: ACME challenges on port 80, fallback page on port 8080 (served by master when k3s cluster is down)
<% for my $host (@$f3s_hosts) { for my $prefix (@prefixes) { -%>
server "<%= $prefix.$host %>-port80" {
  listen on * port 80
  log style forwarded
  location "/.well-known/acme-challenge/*" {
    root "/acme"
    request strip 2
  }
  location * {
    block return 302 "https://$HTTP_HOST$REQUEST_URI"
  }
}

server "<%= $prefix.$host %>-port8080" {
  listen on * port 8080
  log style forwarded
  location * {
    # Rewrite all requests to /index.html to show fallback page regardless of path
    request rewrite "/index.html"
    root "/htdocs/f3s_fallback"
  }
}
<% } } -%>

# Defaults
server "default" {
  listen on * port 80
  log style forwarded 
  block return 302 "https://foo.zone$REQUEST_URI"
}

server "default" {
  listen on * port 8080
  log style forwarded 
  block return 302 "https://foo.zone$REQUEST_URI"
}