diff --git a/internal/web/actions/default/servers/groups/group/settings/httpReverseProxy/setting.go b/internal/web/actions/default/servers/groups/group/settings/httpReverseProxy/setting.go index 80dccf51..0c3bab68 100644 --- a/internal/web/actions/default/servers/groups/group/settings/httpReverseProxy/setting.go +++ b/internal/web/actions/default/servers/groups/group/settings/httpReverseProxy/setting.go @@ -87,15 +87,26 @@ func (this *SettingAction) RunPost(params struct { return } + // PROXY Protocol + var proxyProtocolJSON = []byte{} + if reverseProxyConfig.ProxyProtocol != nil { + proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol) + if err != nil { + this.ErrorPage(err) + return + } + } + // 设置反向代理相关信息 _, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{ - ReverseProxyId: reverseProxyConfig.Id, - RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), - RequestHost: reverseProxyConfig.RequestHost, - RequestURI: reverseProxyConfig.RequestURI, - StripPrefix: reverseProxyConfig.StripPrefix, - AutoFlush: reverseProxyConfig.AutoFlush, - AddHeaders: reverseProxyConfig.AddHeaders, + ReverseProxyId: reverseProxyConfig.Id, + RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), + RequestHost: reverseProxyConfig.RequestHost, + RequestURI: reverseProxyConfig.RequestURI, + StripPrefix: reverseProxyConfig.StripPrefix, + AutoFlush: reverseProxyConfig.AutoFlush, + AddHeaders: reverseProxyConfig.AddHeaders, + ProxyProtocolJSON: proxyProtocolJSON, }) this.Success() diff --git a/internal/web/actions/default/servers/groups/group/settings/tcpReverseProxy/setting.go b/internal/web/actions/default/servers/groups/group/settings/tcpReverseProxy/setting.go index 77424a65..09c13ed7 100644 --- a/internal/web/actions/default/servers/groups/group/settings/tcpReverseProxy/setting.go +++ b/internal/web/actions/default/servers/groups/group/settings/tcpReverseProxy/setting.go @@ -87,15 +87,26 @@ func (this *SettingAction) RunPost(params struct { return } + // PROXY Protocol + var proxyProtocolJSON = []byte{} + if reverseProxyConfig.ProxyProtocol != nil { + proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol) + if err != nil { + this.ErrorPage(err) + return + } + } + // 设置反向代理相关信息 _, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{ - ReverseProxyId: reverseProxyConfig.Id, - RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), - RequestHost: reverseProxyConfig.RequestHost, - RequestURI: reverseProxyConfig.RequestURI, - StripPrefix: reverseProxyConfig.StripPrefix, - AutoFlush: reverseProxyConfig.AutoFlush, - AddHeaders: reverseProxyConfig.AddHeaders, + ReverseProxyId: reverseProxyConfig.Id, + RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), + RequestHost: reverseProxyConfig.RequestHost, + RequestURI: reverseProxyConfig.RequestURI, + StripPrefix: reverseProxyConfig.StripPrefix, + AutoFlush: reverseProxyConfig.AutoFlush, + AddHeaders: reverseProxyConfig.AddHeaders, + ProxyProtocolJSON: proxyProtocolJSON, }) this.Success() diff --git a/internal/web/actions/default/servers/server/settings/locations/reverseProxy/setting.go b/internal/web/actions/default/servers/server/settings/locations/reverseProxy/setting.go index 9c520584..a21c9056 100644 --- a/internal/web/actions/default/servers/server/settings/locations/reverseProxy/setting.go +++ b/internal/web/actions/default/servers/server/settings/locations/reverseProxy/setting.go @@ -78,15 +78,26 @@ func (this *SettingAction) RunPost(params struct { return } + // PROXY Protocol + var proxyProtocolJSON = []byte{} + if reverseProxyConfig.ProxyProtocol != nil { + proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol) + if err != nil { + this.ErrorPage(err) + return + } + } + // 设置反向代理相关信息 _, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{ - ReverseProxyId: reverseProxyConfig.Id, - RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), - RequestHost: reverseProxyConfig.RequestHost, - RequestURI: reverseProxyConfig.RequestURI, - StripPrefix: reverseProxyConfig.StripPrefix, - AutoFlush: reverseProxyConfig.AutoFlush, - AddHeaders: reverseProxyConfig.AddHeaders, + ReverseProxyId: reverseProxyConfig.Id, + RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), + RequestHost: reverseProxyConfig.RequestHost, + RequestURI: reverseProxyConfig.RequestURI, + StripPrefix: reverseProxyConfig.StripPrefix, + AutoFlush: reverseProxyConfig.AutoFlush, + AddHeaders: reverseProxyConfig.AddHeaders, + ProxyProtocolJSON: proxyProtocolJSON, }) this.Success() diff --git a/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go b/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go index e4bf9f08..fb5d430f 100644 --- a/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go +++ b/internal/web/actions/default/servers/server/settings/reverseProxy/setting.go @@ -106,20 +106,31 @@ func (this *SettingAction) RunPost(params struct { return } + // PROXY Protocol + var proxyProtocolJSON = []byte{} + if reverseProxyConfig.ProxyProtocol != nil { + proxyProtocolJSON, err = json.Marshal(reverseProxyConfig.ProxyProtocol) + if err != nil { + this.ErrorPage(err) + return + } + } + // 设置反向代理相关信息 _, err = this.RPC().ReverseProxyRPC().UpdateReverseProxy(this.AdminContext(), &pb.UpdateReverseProxyRequest{ - ReverseProxyId: reverseProxyConfig.Id, - RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), - RequestHost: reverseProxyConfig.RequestHost, - RequestURI: reverseProxyConfig.RequestURI, - StripPrefix: reverseProxyConfig.StripPrefix, - AutoFlush: reverseProxyConfig.AutoFlush, - AddHeaders: reverseProxyConfig.AddHeaders, - ConnTimeoutJSON: connTimeoutJSON, - ReadTimeoutJSON: readTimeoutJSON, - IdleTimeoutJSON: idleTimeoutJSON, - MaxConns: types.Int32(reverseProxyConfig.MaxConns), - MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns), + ReverseProxyId: reverseProxyConfig.Id, + RequestHostType: types.Int32(reverseProxyConfig.RequestHostType), + RequestHost: reverseProxyConfig.RequestHost, + RequestURI: reverseProxyConfig.RequestURI, + StripPrefix: reverseProxyConfig.StripPrefix, + AutoFlush: reverseProxyConfig.AutoFlush, + AddHeaders: reverseProxyConfig.AddHeaders, + ConnTimeoutJSON: connTimeoutJSON, + ReadTimeoutJSON: readTimeoutJSON, + IdleTimeoutJSON: idleTimeoutJSON, + MaxConns: types.Int32(reverseProxyConfig.MaxConns), + MaxIdleConns: types.Int32(reverseProxyConfig.MaxIdleConns), + ProxyProtocolJSON: proxyProtocolJSON, }) if err != nil { this.ErrorPage(err) diff --git a/web/public/js/components/server/reverse-proxy-box.js b/web/public/js/components/server/reverse-proxy-box.js index 27808021..531f85e7 100644 --- a/web/public/js/components/server/reverse-proxy-box.js +++ b/web/public/js/components/server/reverse-proxy-box.js @@ -39,6 +39,14 @@ Vue.component("reverse-proxy-box", { reverseProxyConfig.idleTimeout = {count: 0, unit: "second"} } + if (reverseProxyConfig.proxyProtocol == null) { + // 如果直接赋值Vue将不会触发变更通知 + Vue.set(reverseProxyConfig, "proxyProtocol", { + isOn: false, + version: 1 + }) + } + let forwardHeaders = [ { name: "X-Real-IP", @@ -116,6 +124,13 @@ Vue.component("reverse-proxy-box", { } this.reverseProxyConfig.maxIdleConns = maxIdleConns }, + "reverseProxyConfig.proxyProtocol.version": function (v) { + let version = parseInt(v) + if (isNaN(version)) { + version = 1 + } + this.reverseProxyConfig.proxyProtocol.version = version + } }, methods: { isOn: function () { @@ -194,7 +209,7 @@ Vue.component("reverse-proxy-box", {
可以把请求的路径部分前缀去除后再查找文件,比如把 /web/app/index.html 去除前缀 /web 后就变成 /app/index.html。
-源站保持等待的空闲超时时间,0表示使用默认时间。
选中后表示启用PROXY Protocol,每次连接源站时都会在头部写入客户端地址信息。
+发送类似于
发送二进制格式的头部信息。
+