Skip to content

Commit 0e02820

Browse files
committed
feat hepa api proxy host pass-through set default as true
1 parent 7b69390 commit 0e02820

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

internal/tools/orchestrator/hepa/apipolicy/policies/proxy/policy.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818
"encoding/json"
1919
"fmt"
2020

21+
"github.com/erda-project/erda/internal/tools/orchestrator/hepa/config"
22+
2123
"github.com/pkg/errors"
2224

2325
"github.com/erda-project/erda/internal/tools/orchestrator/hepa/apipolicy"
@@ -42,7 +44,7 @@ func (policy Policy) CreateDefaultConfig(gatewayProvider string, ctx map[string]
4244
ClientRespTimeout: 60,
4345
ProxyReqTimeout: 60,
4446
ProxyRespTimeout: 60,
45-
HostPassthrough: false,
47+
HostPassthrough: config.APIProxyPolicyHostPassThrough(),
4648
SSLRedirect: true,
4749
}
4850
dto.Switch = false

internal/tools/orchestrator/hepa/config/config.go

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414

1515
package config
1616

17+
import "github.com/erda-project/erda/pkg/envconf"
18+
19+
type Conf struct {
20+
APIProxyPolicyHostPassThrough bool `file:"api_proxy_policy_host_pass_through" default:"true"`
21+
}
22+
23+
var cfg Conf
24+
25+
func Load() {
26+
envconf.MustLoad(&cfg)
27+
}
28+
29+
func APIProxyPolicyHostPassThrough() bool {
30+
return cfg.APIProxyPolicyHostPassThrough
31+
}
32+
1733
var ServerConf *ServerConfig
1834
var LogConf *LogConfig
1935

internal/tools/orchestrator/hepa/provider.go

+2
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ type provider struct {
5151
}
5252

5353
func (p *provider) Init(ctx servicehub.Context) error {
54+
config.Load()
5455
config.ServerConf = &p.Cfg.Server
5556
config.LogConf = &p.Cfg.Log
5657
common.InitLogger()
5758
orm.Init()
5859
logrus.Info(version.String())
5960
logrus.Infof("server conf: %+v", config.ServerConf)
6061
logrus.Infof("log conf: %+v", config.LogConf)
62+
logrus.Infof("default api proxy policy host pass through: %v", config.APIProxyPolicyHostPassThrough())
6163
orgCache.CacheInit(p.Org)
6264
p.HttpServer.GET("/api/gateway/openapi/metrics/*", func(resp http.ResponseWriter, req *http.Request) {
6365
path := strings.Replace(req.URL.Path, "/api/gateway/openapi/metrics/charts", "/api/metrics", 1)

0 commit comments

Comments
 (0)