How to get server listen port by placeholder

{http.request.port} get port part of the request’s Host header, but it maybe return empty.
for https, the port 443 will be ommited.

how to get server listen port when the Host header missing port.

caddy version: v2.5.2

The port should only be empty when it’s the default HTTP or HTTPS port, so you can use a request matcher on the protocol + the vars directive to make a new variable that has the value you expect.

But it’s unclear why you need this. Why are you trying to get this port? Please completely fill out the help topic template, as per the forum rules. It’s important to understand the context for your question, because it will probably affect the solution we can suggest.