1. The problem I’m having:
A noob question..
I try to use reverse proxy in a local network. The SERVER 192.168.1.13 hosts caddy service and several other services in different ports: 8096, 3001 etc. all with http only.
I have several names serv1.loc serv2.loc serv3.loc all pointing to 192.168.1.13
Is it possible to do some reverse proxy like this:
http://serv1.loc -> http://192.168.1.13:8096
http://serv2.loc -> http://192.168.1.13:3001
http://serv3.loc -> http://192.168.1.13:3002
etc.
So that we can enter in the browser http://serv1.loc to get the service in port 8096 directly.
I don’t want my family members to enter the port #
2. Error messages and/or full log output:
There is a mismatch…
3. Caddy version:
v2 in nixos unstable
4. How I installed and ran Caddy:
nixos unstable
Thx all 
Create this in your Caddyfile
:
http://serv1.loc {
reverse_proxy http://192.168.1.13:8096
}
http://serv2.loc {
reverse_proxy http://192.168.1.13:3001
}
http://serv3.loc {
reverse_proxy http://192.168.1.13:3002
}
You possibly can replace 192.168.1.13
with 127.0.0.1
in the Caddyfile
configuration.
1 Like
Thx timelordx,
I did this ! Do you think it is the orthodox way?
in fact 192.168.1.13 is a tailnet adress.
Putting http://serv1.loc in my browser serves nextcloud (with errors of course) instead of jellyfin expected…if I dont add the port in the browser (aka http://serv1.loc:8096 and I think this is not served by caddy) I dont get jellyfin.
http://serv1.loc → http://serv1.loc:80 or the first line of my caddy file pointing to nextcloud.
btw I do these experiment from laptop connected to my phone.
What’s the orthodox way?
If that’s the case, it sounds like your Nextcloud is already using port 80 on all network interfaces, so Caddy won’t be able to listen on port 80.
Ah thx but I tried to avoid that, I put nextcloud in a nix container, see:
In the caddy SERVER I have these ips: (thes are not the actual adresses ok?)
192.168.3.13 tailnet adress
192.168.1.15 local adress
192.150.0.14 given by container network
nextcloud is inside a nix container with
192.150.0.15 adress
So nextxloud is well served by
http://nextcloud.loc {
reverse_proxy http://192.150.0.15:80
}
with nextcloud.loc = 192.168.3.13
+++++++++++++++++++++++++++++++++++
orthodox means here:
is caddy working like you say:
http://serv1.loc {
reverse_proxy http://192.168.1.13:8096
}
http://serv2.loc {
reverse_proxy http://192.168.1.13:3001
}
http://serv3.loc {
reverse_proxy http://192.168.1.13:3002
}
with serv1.loc serv2.loc serv3.loc pointing in the same LOCAL (here tailscale=VPN IP) ip ?
I think I did some port forwarding 80<->80 between SERVER and nextcloud container. So maybe you are right nextcloud is listening in port 80 on SERVER ! Thx. I will check out in a few days when code is available ..stay tune and thx to point out the main point 
1 Like