【问题标题】:WCF Service under loadbalancer problem负载均衡器问题下的 WCF 服务
【发布时间】:2011-04-19 21:12:41
【问题描述】:

在负载均衡器 (bigip/f5) 环境中,网站设置为在 asp.net 4.0 下运行后,WCF 服务无法正常工作。 Javascript 代理请求在 asp.net 4 下作为 http 而不是 https,这导致 JS 中出现“访问被拒绝”错误。

在以前版本的 asp.net 上相同的工作没有问题。有什么想法吗??

【问题讨论】:

    标签: wcf load-balancing f5


    【解决方案1】:

    这是has been reported to Microsoft on Connect 的 .NET4 回归(请投票),但微软目前还没有修复。目前,我们编写了一些 F5 规则,这些规则会在退出时重写内容中的协议。糟透了,但不必在应用程序级别进行任何更改(例如编写自定义 HttpModule)。

    首先我们检查它是否是我们甚至必须处理请求,如果是,我们标记并从客户端删除 Accept-Encoding 标头,否则如果内容被 GZipped 在回来的路:

    when HTTP_REQUEST
    {
       set normalizedPath [string toupper [HTTP::path]]
    
       if {$normalizedPath ends_with ".SVC/JS" || $normalizedPath ends_with ".SVC/JSDEBUG"}
       {
           set needToFixSvcReference 1
    
           if {[HTTP::header exists "Accept-Encoding"]}
           {
               HTTP::header remove "Accept-Encoding"
           }
       }
       else
       {
          set needToFixSvcReference 0
       }
    }
    

    然后对于响应处理,我们检查是否应该弄乱响应,如果是,我们收集内容:

    when HTTP_RESPONSE {
       if($needToFixSvcReference equals 1)
       {
           # grab the response
           if { [HTTP::header exists "Content-Length"] }
           {
              set content_length [HTTP::header "Content-Length"]
           }
           else
           {
              set content_length 20000
           }
    
    
           if { $content_length > 0 }
           {
                HTTP::collect $content_length
           }
       }
    }
    

    然后我们再次检查我们是否应该对此响应执行任何操作并将任何set_path("http 替换为set_path("https

    when HTTP_RESPONSE_DATA {
        if { $needToFixSvcReference equals 1 } 
        {
            HTTP::payload replace 0 [HTTP::payload length] [string map {set_path("http set_path("https}[HTTP::payload]]
            HTTP::release
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2013-04-11
      • 2022-01-24
      • 2013-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-06
      • 1970-01-01
      • 2011-05-07
      相关资源
      最近更新 更多