Hosting my tiny sites with Caddy straight from the terminal

Hey all I’m Gjergji

I’m sharing a story about my side project testmyapp.io and how you can use it too GitHub - Gjergj/testmyapp: Cli for testmyapp.io

I’ve always worked on backend software developer and web development has always seemed alien to me.

Decided to changed that this year and started learning HTML/CSS and then moved to Vue.

However I needed to host my toy projects and share them with friends.

I was familiar with Caddy and I knew that could do that just fine.

But I didn’t want to FTP my files to a server and then run Caddy. I wanted to do everything from the terminal.

So I built a small service that sits along side caddy that exposes an API which allows me upload a new site and creates a subdomain in caddy.

I had a basic caddy file initially setup three routes testmyapp.io (hosting the project website), webapi subdomain and a wildcard where all small projects reside.

I also build a CLI tool that would control all this (first time building CLIs in go).

The CLI uploads a site → the webapi saves the HTML/CSS/JS and creates a subdomain in caddy via the API.

The Caddy api is so nice to work with. I made use of the PUT /config to add a new subdomain and @id to delete a subdomain.

This allows to have a URL for my site in a split second all from the terminal as all assets are uploaded.

Since I enjoyed it so much I thought that others might find it useful so I added auth and everyone can install the CLI and host their tiny sites there. Be aware that there are size limits, CORS is disabled and it only accepts HTML/CSS/JS and a few image formats.

An example https://01hjhsx5xh685yvp5ar93507h9.testmyapp.io/

Happy to share more details if you have any questions.

ps. I’ve also been working on a GUI for Caddy and will share about it here in the future

Cheers

2 Likes

Very neat!! Thank you for sharing!

Brilliant :100:

1 Like