mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-21 06:16:31 -04:00
httpserver: Implement {sever_port} placeholder (#2424)
This commit is contained in:
@@ -506,6 +506,16 @@ func (r *replacer) getSubstitution(key string) string {
|
||||
return cert.NotBefore.Format("Jan 02 15:04:05 2006 MST")
|
||||
}
|
||||
return r.emptyValue
|
||||
case "{server_port}":
|
||||
_, port, err := net.SplitHostPort(r.request.Host)
|
||||
if err != nil {
|
||||
if r.request.TLS != nil {
|
||||
return "443"
|
||||
} else {
|
||||
return "80"
|
||||
}
|
||||
}
|
||||
return port
|
||||
default:
|
||||
// {labelN}
|
||||
if strings.HasPrefix(key, "{label") {
|
||||
|
||||
Reference in New Issue
Block a user