V2: how can caddyfile reverse_proxy to JSON

1. Caddy version (caddy version):


2. How I run Caddy:

in a terminal:
./caddy run -config caddy.json

a. System environment:

ubuntu 1804

b. Command:

./caddy run -config caddy.json

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

    "apps": {
        "http": {
            "servers": {
                "example2": {
                    "listen": [
                    "routes": [
                            "handle": [
                                    "handler": "reverse_proxy",
                                    "transport": {
                                        "protocol": "http",
                                        "read_buffer_size": 4096
                                    "upstreams": [
                                            "dial": ""

3. The problem I’m having:

now, i want to proxy a /subpath to
in caddy1, i can do it: {
proxy /subpath

in caddy2, how do i need to write the json file ???

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

The easiest thing to do if when learning to write JSON configs with Caddy is to write what you want as a v2 Caddyfile then adapt it to JSON with the caddy adapt command.

In Caddy v2, it would look like either of these, depending on whether your upstream service expects the subpath to be stripped or not.

With stripping:

handle_path /subpath/* {

Without stripping:

reverse_proxy /subpath/*

I’ve been struggling a bit with this (noob)

Got reverse proxy working like this

rewrite / /ui
reverse_proxy localhost:1880

But also need access to backend subdirectory /admin
If I put in another rewrite I get stuck in password auth loop…

@jesperuk please open a new thread and fill out the template. There’s not enough information here to effectively help you.

This topic was automatically closed after 30 days. New replies are no longer allowed.