diff --git a/community/BluemapLazyServer.md b/community/BluemapLazyServer.md index a2bc31d..587d1a5 100644 --- a/community/BluemapLazyServer.md +++ b/community/BluemapLazyServer.md @@ -52,7 +52,7 @@ config since you'll need it later. Because the Minecraft server (and therefore the integrated BlueMap webserver) is not always going to be online, we need to use something else to host the BlueMap webapp and resources. This guide will -provide a configuration example for [Nginx], but the same general idea can be applied to any other +provide configuration examples for [Nginx] and [Caddy], but the same general idea can be applied to any other webserver as well. Most of this configuration is going to be the exact same as is detailed on the [External Webservers @@ -118,6 +118,53 @@ server { } } ``` + +## Example Caddy config + +``` +yourdomain.com { + # Path to bluemap-webroot, BlueMap can also be used in a sub-folder .. just adapt the paths accordingly + root * /var/www + + # Catch the error and serve "live" data from the disk when the integrated webserver can't be reached + handle_errors { + try_files {path} =204 + file_server { + # Replace the error status preserved from the reverse_proxy directive + status 200 + } + } + + # Match the textures.json file & .prbm files + @gz path /maps/*/textures.json *.prbm + # Find .gz files (if not found respond with 204) for the above matcher, and set the "Content-Encoding gzip" header + handle @gz { + try_files {path}.gz =204 + header Content-Encoding gzip + } + + # Respond with 204 for non-existant map-tiles + @204 path */tiles/* + handle @204 { + try_files {path} =204 + } + + # Proxy requests for live data to the bluemaps integrated webserver. + # Trigger an error and fall back to our local files if the server can't be reached. + @live path /maps/*/live/* + handle @live { + reverse_proxy 127.0.0.1:8100 { # Adapt to your setup + # We don't want the request to hang indefinitely so we trigger a timeout error after 3s + transport http { + response_header_timeout 3s + } + } + } + + file_server +} +``` + > **Important:**
> The above config is **just an example** and not a complete config you can just copy&paste. You > **will** need to adapt it to your setup! @@ -126,5 +173,6 @@ server { [lazymc]:https://github.com/timvisee/lazymc [Nginx]: https://nginx.org/ + [Caddy]: https://caddyserver.com/ [External Webservers (FILE-Storage)]: {% link wiki/webserver/ExternalWebserversFile.md %} [Getting Started]: {% link wiki/getting-started/index.md %}