Well, there’re too many circumstances in this regard,
Below, is my working configurations as I already use caddy as master proxy providing access to anything i may choose from anywhere i.e. outside LAN considering NAT forwarding and firewalls settings are routed correctly.
In the above example, caddy is listening to port 443 on the machine facing WAN so that all requests to chat.domain.com will be directed to another machine at which the service - say chat - is listening to port 5443.
Thanks for the reply. Actually I tried a lot different ways, with or without trailing slashes, etc., I suspect there might be some stupid mistake with my URL, for example, it works to access the original URL:
By default, Caddy proxies whatever matches the basepath (in your case /api) to the upstream, preserving the entire URI (including /api).
So your endpoint works when you query http://some-lan-server:2017/some/path, but Caddy is actually requesting http://some-lan-server:2017/api/some/path.
To fix this, you’ll want to use the without subdirective, to strip the /api prefix from the request before sending it upstream.