Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
Last active November 13, 2023 09:06
Show Gist options
  • Save barseghyanartur/3e8c6ae983f7c3c1a3a2568e9ca7789f to your computer and use it in GitHub Desktop.
Save barseghyanartur/3e8c6ae983f7c3c1a3a2568e9ca7789f to your computer and use it in GitHub Desktop.
Caddy proxy

Caddy

Installation

sudo snap install caddy --edge

Configuration

Create a Caddyfile with the following content:

:3000 {
    reverse_proxy localhost:3001

    log {
        output stdout
        format json
    }
}

This would serve as a proxy for a NodeJS application running on port 3001. The port caddy will be running on would be 3000.

For logging (JSON format), add the tiny bits:

:3000 {
    reverse_proxy localhost:3001

    log {
        output stdout
        format json
    }
}

For logging (console format), do as follows:

:3000 {
    reverse_proxy localhost:3001

    log {
        output stdout
        format console
    }
}

Running

Caddy

caddy run

NodeJS

yarn dev --port 3001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment