新建反向代理时默认选中所有Header

This commit is contained in:
刘祥超
2021-02-07 09:08:46 +08:00
parent 3252c08fb6
commit f4a915c98e

View File

@@ -159,7 +159,13 @@ func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userI
op.State = ReverseProxyStateEnabled op.State = ReverseProxyStateEnabled
op.AdminId = adminId op.AdminId = adminId
op.UserId = userId op.UserId = userId
op.AddHeaders = "[\"X-Real-IP\"]"
defaultHeaders := []string{"X-Real-IP", "X-Forwarded-For", "X-Forwarded-By", "X-Forwarded-Host", "X-Forwarded-Proto"}
defaultHeadersJSON, err := json.Marshal(defaultHeaders)
if err != nil {
return 0, err
}
op.AddHeaders = defaultHeadersJSON
if len(schedulingJSON) > 0 { if len(schedulingJSON) > 0 {
op.Scheduling = string(schedulingJSON) op.Scheduling = string(schedulingJSON)
@@ -170,7 +176,7 @@ func (this *ReverseProxyDAO) CreateReverseProxy(tx *dbs.Tx, adminId int64, userI
if len(backupOriginsJSON) > 0 { if len(backupOriginsJSON) > 0 {
op.BackupOrigins = string(backupOriginsJSON) op.BackupOrigins = string(backupOriginsJSON)
} }
err := this.Save(tx, op) err = this.Save(tx, op)
if err != nil { if err != nil {
return 0, err return 0, err
} }