TsgcWebSocketLoadBalancerServer › 属性 › SecurityOptions
定义准入规则,例如到达负载均衡器的 WebSocket 握手的允许来源。
property SecurityOptions: TsgcWSSecurity_Options read FSecurityOptions write SetSecurityOptions;
OriginsAllowed=""(允许所有来源)
使用 OriginsAllowed 限制负载均衡器接受 WebSocket 握手的浏览器来源。默认情况下允许所有来源;任何非空值都会启用白名单,负载均衡器将关闭 Origin 标头不匹配的连接,甚至在选择后端之前。模式支持端口通配符(例如 http://127.0.0.1:5555 或 http://127.0.0.1:*)。多个来源用逗号分隔。将 OriginsAllowed 设置为空字符串将恢复宽松的默认值。
oServer := TsgcWebSocketLoadBalancerServer.Create(nil);
oServer.SecurityOptions.OriginsAllowed := 'https://app.example.com';
oServer.Active := true;