V2 reverse proxy transparent/websocket

1. Caddy version (caddy version):

V2.0.0 full release not rc. I build with xcaddy and lego deprecated

2. How I run Caddy:

for now just doing a small test to get the basics going

so

caddyfile V2

(r53) {
   tls {
      dns lego_deprecated route53
    }
}
# Main http/https redirect for anything arriving on port 80/http
*.kebler.net:80 {
   redir https://{label1}.kebler.net{uri}
}

# Git Server
https://git.238.kebler.net {
    import r53
    reverse_proxy / http://nas.kebler.net:3000
    }

# Home Assistant Server
https://ha.238.kebler.net {
    import r53
    reverse_proxy / hassio.kebler.net:8123 {
    }
    }

here was my working V1 for those two urls

# Git Server
https://git.238.kebler.net {
         proxy / http://nas.kebler.net:3000
         }

# Home Assistant Server
https://ha.238.kebler.net {
         proxy / hassio.kebler.net:8123 {
           websocket
           transparent
           }
         }

a. System environment:

amd64 ubuntu bionic

b. Command:

#!/bin/bash
source /opt/caddy2/test-server/aws_env.sh
sudo -E /usr/bin/env | grep AWS
sudo -E /opt/caddy2/test-server/caddy run --config /opt/caddy2/test-server/caddy.conf --adapter caddyfile

3. The problem I’m having/tried

first off I read through these but one is from Nov 19 and the other 18. long before this official release. None of that there helped me.

In the git.238.kebler.net case the site is not fully rendering. Looks like at the very least css is missing from the header. I did not need transparent in V1 so wondering why v2 is not working

for ha.238.kebler.net pretty similar problem. Nothing is rendering of home assistant except the underlying skeleton page.
In that case I did use transparent in V1 but I thought in V2 “transparent” is included by default for reverse proxy. I tried a few suggestions based on that old post to no avail.

========================

Thanks for filling out the template!

In v2, path matchers are exact. (In v1, it was impossible to match on a path that was also a prefix of other paths, without matching all the other paths too!)

This is explained here in our upgrade guide: Upgrading to Caddy 2 — Caddy Documentation

Also here in our matcher docs: Request matchers (Caddyfile) — Caddy Documentation

Path matching is an exact match by default; you must append a * for a fast prefix match. Note that /foo* will match /foo and /foo/ as well as /foobar ; you might actually want /foo/* instead.

If your intention is to match all requests, you can remove the matcher entirely.

Hope that helps!

Well that turned out to be a very simple fix once I understood how the path matching has changed.

All that was needed was to remove the root / from the reverse proxy line or change it to /*. A small detail I didn’t pick up on initially. It explains why it only loaded the root path stuff and nothing else.

@matt after a few “getting hit on the head lessons” I’m finally feeling some love from V2. I have yet to xfer all the rest of my V1 caddyfile so I expect some more issues (e.g. nextcloud, quasar webapp) but hopefully won’t be too painful from here on out. So yes thx for your, @Whitestrake, @francislavoie and other’s efforts. If you wanted V2 to be a giant killer (nginx,apache) you have succeeded and the web management interface would be the dancing on their graves.

3 Likes

reverse_proxy * localhost:7080 is what I used to match all :slight_smile:

The * is only necessary if the first argument to your directive starts with a /, in which case it would be ambiguous which is the argument and which is a matcher. In your case, you can omit the * safely!

2 Likes

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