Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix invalid warning #54

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions reverseproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,14 @@ func (r *ReverseProxy) AddSubdomain(subdomain string, ipaddress string, targetPo
}

// create reverse proxy
proxy := false
for _, v := range r.cfg.Listen.HTTP {
if v.TargetPort != targetPort {
if !r.cfg.localMode {
log.Printf("[warn] target port %d is not defined in config.", targetPort)
continue
}
if (v.TargetPort != targetPort) && !r.cfg.localMode {
continue
// local mode allows any port
}
if ph.exists(v.ListenPort, addr) {
proxy = true
continue
}
destUrlString := "http://" + addr
Expand All @@ -237,8 +236,14 @@ func (r *ReverseProxy) AddSubdomain(subdomain string, ipaddress string, targetPo
}
handler.Transport = tp
ph.add(v.ListenPort, addr, handler)
proxy = true
log.Printf("[info] add subdomain: %s:%d -> %s", subdomain, v.ListenPort, addr)
}
if !proxy {
log.Printf("[warn] proxy of subdomain %s(target port %d) is not created. define target port in listen.http[]", subdomain, targetPort)
return
}

r.domainMap[subdomain] = ph
for _, name := range r.domains {
if name == subdomain {
Expand Down
Loading