Skip to content

Commit 50f1de5

Browse files
authored
Update BluemapLazyServer.md - Caddy example (#107)
* Update BluemapLazyServer.md - Caddy example Added a configuration example for Caddy based on the official wiki for hosting with external webservers and my own trial and error. * Correct indentation and code highlighting Correct indentation formatting and useless highlighting on the code block.
1 parent 9304ef4 commit 50f1de5

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

community/BluemapLazyServer.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ config since you'll need it later.
5252

5353
Because the Minecraft server (and therefore the integrated BlueMap webserver) is not always going to
5454
be online, we need to use something else to host the BlueMap webapp and resources. This guide will
55-
provide a configuration example for [Nginx], but the same general idea can be applied to any other
55+
provide configuration examples for [Nginx] and [Caddy], but the same general idea can be applied to any other
5656
webserver as well.
5757

5858
Most of this configuration is going to be the exact same as is detailed on the [External Webservers
@@ -118,6 +118,53 @@ server {
118118
}
119119
}
120120
```
121+
122+
## Example Caddy config
123+
124+
```
125+
yourdomain.com {
126+
# Path to bluemap-webroot, BlueMap can also be used in a sub-folder .. just adapt the paths accordingly
127+
root * /var/www
128+
129+
# Catch the error and serve "live" data from the disk when the integrated webserver can't be reached
130+
handle_errors {
131+
try_files {path} =204
132+
file_server {
133+
# Replace the error status preserved from the reverse_proxy directive
134+
status 200
135+
}
136+
}
137+
138+
# Match the textures.json file & .prbm files
139+
@gz path /maps/*/textures.json *.prbm
140+
# Find .gz files (if not found respond with 204) for the above matcher, and set the "Content-Encoding gzip" header
141+
handle @gz {
142+
try_files {path}.gz =204
143+
header Content-Encoding gzip
144+
}
145+
146+
# Respond with 204 for non-existant map-tiles
147+
@204 path */tiles/*
148+
handle @204 {
149+
try_files {path} =204
150+
}
151+
152+
# Proxy requests for live data to the bluemaps integrated webserver.
153+
# Trigger an error and fall back to our local files if the server can't be reached.
154+
@live path /maps/*/live/*
155+
handle @live {
156+
reverse_proxy 127.0.0.1:8100 { # Adapt to your setup
157+
# We don't want the request to hang indefinitely so we trigger a timeout error after 3s
158+
transport http {
159+
response_header_timeout 3s
160+
}
161+
}
162+
}
163+
164+
file_server
165+
}
166+
```
167+
121168
> **Important:**<br>
122169
> The above config is **just an example** and not a complete config you can just copy&paste. You
123170
> **will** need to adapt it to your setup!
@@ -126,5 +173,6 @@ server {
126173

127174
[lazymc]:https://github.com/timvisee/lazymc
128175
[Nginx]: https://nginx.org/
176+
[Caddy]: https://caddyserver.com/
129177
[External Webservers (FILE-Storage)]: {% link wiki/webserver/ExternalWebserversFile.md %}
130178
[Getting Started]: {% link wiki/getting-started/index.md %}

0 commit comments

Comments
 (0)