Caddy
This example uses Caddy, one of the most popular web servers.
Caddy can be used with Unikraft / Unikraft Cloud to serve static web content.
To run this example, follow these steps:
-
Install the CLI. Use the unikraft CLI or the legacy kraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.
The unikraft CLI is the current standard, while kraft is the legacy version. Choose one of the CLIs below and only run the commands associated with it for the rest of this guide.
-
Clone the
examplesrepository andcdinto theexamples/caddy2.7-go1.21/directory:Code
Make sure to log into Unikraft Cloud and pick a metro close to you.
This guide uses fra (Frankfurt, 🇩🇪):
When done, invoke the following command to deploy this app on Unikraft Cloud:
The output shows the instance address and other details:
In this case, the instance name is caddy27-go121-vhf4m and the address is https://frosty-sky-vz8kwsmb.fra.unikraft.app.
They're different for each run.
Use curl to query the Unikraft Cloud instance of Caddy.
Code
Code
You can list information about the instance by running:
When done, you can remove the instance:
Customize your app
To customize the app, update the files in the repository, listed below:
Kraftfile: the Unikraft Cloud specificationrootfs/var/www/index.html: the index page of the content servedrootfs/etc/caddy/Caddyfile: the Caddy configuration file
Update the contents of the rootfs/var/www directory to serve different static web content.
For example, you could change the contents of rootfs/var/www/index.html to:
Code
After re-deploying the Caddy image on Unikraft Cloud, using curl or a browser to query it will present the new page contents.
You can generate the static web content in rootfs/var/www/ offline with tools such as Jekyll or Hugo.
If required, you can also customize the configuration of Caddy in rootfs/etc/caddy/Caddyfile.
You can set a new webroot (different than rootfs), or a different internal port, or a different index page, etc.
Learn more
Use the --help option for detailed information on using Unikraft Cloud:
Or visit the CLI Reference or the legacy CLI Reference.