Merge pull request #5005 from flycash/dev

fix 4907: force admin service http only
This commit is contained in:
Ming Deng 2022-07-02 17:09:44 +08:00 committed by GitHub
commit 50c4c849da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,6 @@
# developing # developing
- [Fix 4984: random expire cache](https://github.com/beego/beego/pull/4984) - [Fix 4984: random expire cache](https://github.com/beego/beego/pull/4984)
- [Fix 4907: make admin serve HTTP only](https://github.com/beego/beego/pull/5005)
# v2.0.4 # v2.0.4

View File

@ -16,6 +16,7 @@ package web
import ( import (
"fmt" "fmt"
"net"
"net/http" "net/http"
"reflect" "reflect"
"time" "time"
@ -86,7 +87,7 @@ func (admin *adminApp) Run() {
" please invoke task.StartTask, or task will not be executed") " please invoke task.StartTask, or task will not be executed")
addr := BConfig.Listen.AdminAddr addr := BConfig.Listen.AdminAddr
if BConfig.Listen.AdminPort != 0 { if BConfig.Listen.AdminPort != 0 {
addr = fmt.Sprintf("%s:%d", BConfig.Listen.AdminAddr, BConfig.Listen.AdminPort) addr = net.JoinHostPort(BConfig.Listen.AdminAddr, fmt.Sprintf("%d", BConfig.Listen.AdminPort))
} }
logs.Info("Admin server Running on %s", addr) logs.Info("Admin server Running on %s", addr)
admin.HttpServer.Run(addr) admin.HttpServer.Run(addr)
@ -102,6 +103,7 @@ func registerAdmin() error {
// copy config to avoid conflict // copy config to avoid conflict
adminCfg := *BConfig adminCfg := *BConfig
adminCfg.Listen.EnableHTTPS = false adminCfg.Listen.EnableHTTPS = false
adminCfg.Listen.EnableMutualHTTPS = false
beeAdminApp = &adminApp{ beeAdminApp = &adminApp{
HttpServer: NewHttpServerWithCfg(&adminCfg), HttpServer: NewHttpServerWithCfg(&adminCfg),
} }