Skip to content

Webserver Setup With Caddy

PhlexPlexico edited this page Oct 11, 2021 · 7 revisions

Since Caddy can handle SSL and reverse proxy with ease, I figured I would give it a shot and make a small Caddyfile for setup. Follow the installation for your operating system, and get setup by following their install guides.

Next, is the Caddyfile for itself. To get something super basic and up and running (assuming you have G5API setup on the ports/etc), you can use the following Caddyfile. Simply create a new file called "Caddyfile" and adjust what is needed.

HOSTNAME.COM
root * /link/to/dist/folder/
route /api/* {
	uri strip_prefix /api
	reverse_proxy 127.0.0.1:{API_PORT}
}
route {
        try_files {path} {path}/ /index.html
	file_server
}

If you wish to have multiple domains on a single Caddy instance, that can be defined as such as well, per Caddy directives

hostname.com {
    root * /link/to/dist/folder/
    route /api/* {
	    uri strip_prefix /api
	    reverse_proxy 127.0.0.1:{API_PORT}
    }
    route {
            try_files {path} {path}/ /index.html
	    file_server
    }
}

With this done, you can run Caddy with specifying the Caddyfile, and you should be up and running!

Clone this wiki locally