How can I reverse_proxy multiple ports to same domain?

1. The problem I’m having:

I’m trying to use caddy in conjunction with duckdns, I’m trying to reverse proxy multiple ports for various services on my machine.

2. Error messages and/or full log output:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

I have no error message

3. Caddy version:

I am running latest version on windows 11 pro.

4. How I installed and ran Caddy:

I installed caddy using nssm to create service

a. System environment:

I am running windows 11 pro amd64.

b. Command:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

to install caddy I did .\caddy run --config Caddyfile I think.

c. Service/unit/compose file:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

unit is my computer

d. My complete Caddy config:

PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.

this is all that’s in my caddyfile
https://mydomainname.duckdns.org {
reverse_proxy localhost:8000 localhost:8096 localhost:7878 localhost:8989 localhost:7676 localhost:9696
}

currently its just giving me a random page from this assortment. I tried every combination from separating them into their own line and then tried including adding port numbers to the https://mydomainname.duckdns.org:8096 {blah blah} but that doesn’t return anything. I would like to be able to just go to https://mydomainname.duckns.org/ and have it go first to localhost:8000 because that’s the landing page I created then use hyperlinks to take me to other localhost:ports that caddy is pushing. I guess my problem is caddy isn’t pushing those ports, only one or all at the roll of a dice pls help!

I know I can use more subdomains from duckdns but they only allow 5 free subdomains and I have 6 ports. also I am restarting the caddy service after ever time I update the caddy file

5. Links to relevant resources:

Take a look at reverse_proxy directive.

Without specifying a matcher you’re just load balancing between all your listed back-ended. So, the request just goes to any of them.

You can run everything on a single Caddy port, for example, port 443. And use matchers with the reverse_proxy directive to send your traffic to different backends based on different criteria. For example, /path1 to the backend1, /path2 to the backend2, etc.

that is definitely progress lol, this is what my caddyfile says now:

https://mydomainname.duckdns.org {
	reverse_proxy localhost:8000
	reverse_proxy /jellyfin/* localhost:8096
	reverse_proxy /radarr/* localhost:7878
	reverse_proxy /sonarr/* localhost:8989
	reverse_proxy /lidarr/* localhost:8686
	reverse_proxy /prowlarr/* localhost:9696
}

when i go to https://mydomainname.duckdns.org/jellyfin/ for example the page is just grey. when i go to radarr the page is white, the correct names for the webpages are showing up though?

You want to take a look at handle_path directive

Instead of

reverse_proxy /jellyfin/* localhost:8096

try

handle_path /jellyfin/* {
	reverse_proxy localhost:8096
}

etc.

If you’re setting up your services on sub-path, keep this in mind:

my jellyfin is working after doing handle_path but the rest were blank. after doing option 1 and setting a base url for each as their program name when i go to the site i get prompted to login but then the page has a problem loading. firefox says “Firefox has detected that the server is redirecting the request for this address in a way that will never complete.” and edge says redirected too many times and “ERR_TOO_MANY_REDIRECTS”

https://mydomainname.duckdns.org {
	handle_path /jellyfin/* {
		reverse_proxy localhost:8096
	}
	redir /radarr /radarr/
	handle_path /radarr/* {
		reverse_proxy localhost:7878
	}
	redir /sonarr /sonarr/
	handle_path /sonarr/* {
		reverse_proxy localhost:8989
	}
	redir /lidarr /lidarr/
	handle_path /lidarr/* {
		reverse_proxy localhost:8686
	}
	redir /prowlarr /prowlarr/
	handle_path /prowlarr/* {
		reverse_proxy localhost:9696
	}
}

further searching shows it might be an ssl thingy

https://jellyfin.website.com/* {
	reverse_proxy localhost:8096
}
https://radarr.website.com/* {
	reverse_proxy localhost:7878
}
https://sonarr.website.com/* {
	reverse_proxy localhost:8989
}
https://lidarr.website.com/* {
	reverse_proxy localhost:8686
}
https://prowlarr.website.com/* {
	reverse_proxy localhost:9696
}

Remove these

You don’t need them.