Reverse Proxy Ghost blog on Subpath breaking jquery

1. Caddy version (caddy version):

v2.4.0

2. How I run Caddy:

run caddy on local install

a. System environment:

linux ubuntu

b. Command:

caddy run

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

:3000 {
        route / {
                reverse_proxy :2000
        }
        route /blog* {
                uri strip_prefix /blog
                reverse_proxy :2368
        }
}

3. The problem I’m having:

the ghost blog html loads but the styles and js seem to be breaking when i redirect on a subpath /blog*.
if I do not use a subpath, and just route to /, the ghost blog works fine.

4. Error messages and/or full log output:

the jquery file throws error when it loads

jQuery.Deferred exception: $(...).fitVids is not a function TypeError: $(...).fitVids is not a function

5. What I already tried:

tried multiple combinations of caddyfilles

6. Links to relevant resources:

Please upgrade to v2.4.6, there’s plenty of important fixes.

A path matcher of / will only match requests to exactly / and nothing else.

I think what you want is this:

:3000 {
	handle_path /blog* {
		reverse_proxy localhost:2368
	}

	handle {
		reverse_proxy localhost:2000
	}
}

But proxying to a subpath often doesn’t work depending on the paths the upstream app tries to load. See this article which explains in depth:

1 Like

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