From 920dbbef5e4baeefc1cb26ce5ddbb96b8b48161b Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 9 Mar 2022 17:42:56 +0800 Subject: [PATCH] fix: server access logs contain the protocol used between the server and the load balancer, but not the protocol used between the client and the load balancer --- net/ghttp/ghttp_request.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_request.go b/net/ghttp/ghttp_request.go index be5935f41..5c546d164 100644 --- a/net/ghttp/ghttp_request.go +++ b/net/ghttp/ghttp_request.go @@ -225,7 +225,8 @@ func (r *Request) GetRemoteIp() string { // GetUrl returns current URL of this request. func (r *Request) GetUrl() string { scheme := "http" - if r.TLS != nil { + proto := r.Header.Get("X-Forwarded-Proto") + if r.TLS != nil || (proto != "" && strings.ToLower(proto) == "https") { scheme = "https" } return fmt.Sprintf(`%s://%s%s`, scheme, r.Host, r.URL.String())