From 545c3b29c32e8f3543b40d91ebac24d31b47060f Mon Sep 17 00:00:00 2001 From: Weidi Deng Date: Mon, 23 May 2022 11:09:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dunix=E4=B8=8B=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AFip=E4=B8=BA=E7=A9=BA=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=85=8D=E7=BD=AE=E9=A1=B9=E8=AE=BE=E7=BD=AE=E4=BB=8E?= =?UTF-8?q?=E5=93=AA=E4=B8=AAheader=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 1 + pkg/conf/conf.go | 3 ++- pkg/conf/defaults.go | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 815612e6..69e628bb 100644 --- a/main.go +++ b/main.go @@ -76,6 +76,7 @@ func main() { } } + api.TrustedPlatform = conf.UnixConfig.ProxyHeader util.Log().Info("开始监听 %s", conf.UnixConfig.Listen) if err := api.RunUnix(conf.UnixConfig.Listen); err != nil { util.Log().Error("无法监听[%s],%s", conf.UnixConfig.Listen, err) diff --git a/pkg/conf/conf.go b/pkg/conf/conf.go index 35ed8b6a..a9f7d06e 100644 --- a/pkg/conf/conf.go +++ b/pkg/conf/conf.go @@ -35,7 +35,8 @@ type ssl struct { } type unix struct { - Listen string + Listen string + ProxyHeader string `validate:"required_with=Listen"` } // slave 作为slave存储端配置 diff --git a/pkg/conf/defaults.go b/pkg/conf/defaults.go index 44c5371e..eabaee5e 100644 --- a/pkg/conf/defaults.go +++ b/pkg/conf/defaults.go @@ -45,7 +45,8 @@ var SSLConfig = &ssl{ } var UnixConfig = &unix{ - Listen: "", + Listen: "", + ProxyHeader: "X-Forwarded-For", } var OptionOverwrite = map[string]interface{}{}