V2: Reverse Proxy setup problems

1. Caddy version (caddy version):

v2.1.1 h1:X9k1+ehZPYYrSqBvf/ocUgdLSRIuiNiMo7CvyGUQKeA=

2. How I run Caddy:

system service installed from apt repository

a. System environment:

standard ubuntu 18.04

b. Command:

service caddy start

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

paste config here, replacing this text
DO NOT REDACT anything except credentials

test.doobiemailer.com:80 {
reverse_proxy /api/* localhost:9000
reverse_proxy / localhost:8080


3. The problem I’m having:

trying to setup reverse proxy for listmonk.

here is the nginx equivalent of what im trying to get Caddy to do:


server {
listen 9001;

# Proxy all /api/* requests to the Go backend.
location /api {
    proxy_pass http://localhost:9000;

# Proxy everything else to the Vue frontend running on the Yarn server.
location / {
    proxy_pass http://localhost:8080;


4. Error messages and/or full log output:

This site can’t be reached

The connection was reset.



5. What I already tried:

ive read the reverse proxy docs like 20 times and ive tried various versions of the reverse proxy config settings but it always is either a 502 or a ERR_CONNECTION_RESET.

go to test.doobiemailer.com and if its working you should get a login prompt for listmonk.

6. Links to relevant resources:

Developer setup - listmonk / Documentation (bottom of the page)

In Caddy v2, request matching is exact-match, so / will only match requests to /, but not /foo. Just remove the / from your second proxy and it should work – omitting the matcher is the same as *, meaning match anything.

unfortunately i’m still getting ERR_CONNECTION_RESET

What’s in your logs? You can run sudo journalctl --no-pager -u caddy | less to read them, when running Caddy as a systemd service.

Are you sure your app is running and listening on ports 9000 and 8080?

i got it!

reverse_proxy localhost:9000

for some reason omitting the api path seems to make it work!

That’s doing something different than the nginx config describes. You’re now passing every request to the Go backend, and none of the requests are going to the Vue frontend/yarn server.

But if it works, it works :+1:

I got confused. The docs aren’t very good at describing how to setup the reverse proxy for just the regular binary, not the two-app front/back development version (which is where I got the proxy config from to start with). So that’s why it wasn’t working, it was trying to connect to the config for the development server and not the production server.

1 Like

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