Websocket Squid4转发代理以从ws升级到wss

Websocket Squid4转发代理以从ws升级到wss,websocket,squid,gorilla,Websocket,Squid,Gorilla,Squid4.6用作转发代理,将所有流量转换为安全流量。 squid的配置非常简单,它允许所有流量,并使用urlrewrite.pl将“http”替换为“https”。(不使用SSL-BUMP)squid代理设置了tls_outgoing_选项,因此以下工作: 客户端(http)--->Squid------>服务器(https) 现在,我正试图用WebSocket复制同样的功能。 有3个测试用例, 1. 客户端(ws)--->Squid------->服务器(ws) 客户端(wss)--->S

Squid4.6用作转发代理,将所有流量转换为安全流量。 squid的配置非常简单,它允许所有流量,并使用urlrewrite.pl将“http”替换为“https”。(不使用SSL-BUMP)squid代理设置了tls_outgoing_选项,因此以下工作:

客户端(http)--->Squid------>服务器(https)

现在,我正试图用WebSocket复制同样的功能。 有3个测试用例, 1. 客户端(ws)--->Squid------->服务器(ws)

  • 客户端(wss)--->Squid------->服务器(wss)
  • 三, 客户端(ws)--->Squid------->服务器(wss)

    前两种情况对鱿鱼有效,但第三种情况不起作用。我只需要第三个选项。
    我已经给出了urlrewrite.pl的调试日志,以显示收到的websocket连接的确切请求,以下是日志: 这里的端口8080:是服务器,端口3128:是squid

    调试:root:localhost:8080 127.0.0.1/localhost-CONNECT myip=127.0.0.1 myport=3128

    即使是wireshark也表现出同样的情况, 1.连接HTTP 1.1 2.得到 3.升级协议

    问题: 1.有没有办法升级websocket连接以使用squid4.6保护websocket? 2.或者说我使用wss客户端(没有证书)和wss服务器(有证书),有没有办法通知squid使用自己的证书(甚至在“tls_outgoing_options”中提到)来建立连接

    所需: 客户端将始终通过HTTP/WS发送不安全的流量 Squid应该升级到HTTPS/WSS。 在我们的应用程序设置中,我们使用我们自己的openssl库来创建证书-这不能包含在(client.go)go tls包中,因此我们使用squid代理来使用我们自己的openssl库生成的证书。 客户端和转发代理(Squid)都在我们特定的环境中,因此Squid.conf非常简单,允许所有流量。 我们需要相互认证

    SQUID配置代码

    #
    # Recommended minimum configuration:
    #
    
    # Example rule allowing access from your local networks.
    # Adapt to list your (internal) IP networks from where browsing
    # should be allowed
    acl localhost src 127.0.0.1
    
    acl SSL_ports port 443
    acl Safe_ports port 443 # https
    acl Safe_ports port 80  # http
    acl CONNECT method CONNECT
    
    http_access deny !Safe_ports
    http_access deny CONNECT !SSL_ports
    http_access allow localhost
    http_access deny all
    
    # Squid normally listens to port 3128
    http_port 3128
    
    url_rewrite_program /etc/squid/urlrewrite.pl
    url_rewrite_access allow  all
    tls_outgoing_options cert=/etc/squid/proxy.crt
    tls_outgoing_options key=/etc/squid/proxy.key
    tls_outgoing_options cafile=/etc/squid/serverauth.crt
    
    URL重写代码

    #!/usr/bin/perl
    select(STDOUT);
    $| = 1;
    while (<>) {
        #print STDOUT "OK rewrite-url=\"https://google.com\"\n";
    
        if (/^(|\d+\s+)((\w+):\/+)([^\/:]+)(|:(\d+))(|\/\S*)(|\s.*)$/) {
            my $channel = $1;
            my $protocolClean = $3;
            my $domain = $4;
            my $port = $5;
            my $portClean = $6;
            my $urlPath = $7;
    
        if ($protocolClean eq 'http' ){#&& ($port eq '' || $portClean eq '80')) {
               print STDOUT "${channel}OK rewrite-url=\"https://${domain}${port}${urlPath}\"\n";
           #print STDOUT "${channel}OK rewrite-url=\"https://google.com\"\n";
        } else {
               print STDOUT "${channel}ERR\n";
        }
        }
    }
    
    #/usr/bin/perl
    选择(标准输出);
    $| = 1;
    而(){
    #打印标准输出“确定重写url=\”https://google.com\“\n”;
    如果(/^(|\d++\s+(\w+):\/+([^\/:]+)(|:(\d+)(|\/\s*)(|\s.*)$/){
    my$channel=$1;
    my$protocolClean=$3;
    my$domain=$4;
    my$port=$5;
    my$portClean=$6;
    我的$urlPath=$7;
    if($protocolClean eq'http'){#&&($port eq'.| |$portClean eq'80')){
    打印标准输出“${channel}OK rewrite url=\”https://${domain}${port}${urlPath}\”\n;
    #打印标准输出“${channel}确定重写url=\”https://google.com\“\n”;
    }否则{
    打印标准输出“${channel}ERR\n”;
    }
    }
    }