如何正确设置squid3作为HTTPS代理?

我想使用这里给出的教程来设置squid3作为HTTPS代理。 我在浏览器中正确设置了代理设置,当我尝试访问HTTP网站时,我能够成功连接。 但是,每当我点击一个HTTPS协议网站时,我都会收到“连接超时错误”,并在我的/var/log/squid3/cache.log出现以下错误:

 2016/06/20 19:12:47| NF getsockopt(SO_ORIGINAL_DST) failed on local=<local_ip_address>:3129 remote=<remote_ip_address>:55209 FD 8 flags=33: (92) Protocol not available 

这里是我的/etc/squid3/squid.conf文件(为简洁起见删除了注释行):

 auth_param basic program /usr/lib/squid3/basic_ncsa_auth /usr/etc/passwd auth_param basic casesensitive off auth_param basic credentialsttl 2 hours acl user_auth proxy_auth REQUIRED http_access allow user_auth acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow localhost http_access allow all http_port 3127 https_port 3129 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=4MB key=/etc/squid3/example.com.private cert=/etc/squid3/example.com.cert ssl_bump server-first all sslproxy_flags DONT_VERIFY_PEER sslproxy_cert_error deny all sslcrtd_program /usr/lib/squid3/ssl_crtd -s /var/lib/ssl_db -M 4MB sslcrtd_children 8 startup=1 idle=1 coredump_dir /var/spool/squid3 refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880 refresh_pattern . 0 20% 4320 always_direct allow all 

这是我的squid3 -v的输出:

 Squid Cache: Version 3.3.8 (Ubuntu) configure options: '--build=i686-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--libexecdir=${prefix}/lib/squid3' '--srcdir=.' '--disable-maintainer-mode' '--disable-dependency-tracking' '--disable-silent-rules' '--datadir=/usr/share/squid3' '--sysconfdir=/etc/squid3' '--mandir=/usr/share/man' '--enable-inline' '--enable-async-io=8' '--enable-ssl' '--enable-ssl-crtd' '--enable-storeio=ufs,aufs,diskd,rock' '--enable-removal-policies=lru,heap' '--enable-delay-pools' '--enable-cache-digests' '--enable-underscores' '--enable-icap-client' '--enable-follow-x-forwarded-for' '--enable-auth-basic=DB,fake,getpwnam,LDAP,MSNT,MSNT-multi-domain,NCSA,NIS,PAM,POP3,RADIUS,SASL,SMB' '--enable-auth-digest=file,LDAP' '--enable-auth-negotiate=kerberos,wrapper' '--enable-auth-ntlm=fake,smb_lm' '--enable-external-acl-helpers=file_userip,kerberos_ldap_group,LDAP_group,session,SQL_session,unix_group,wbinfo_group' '--enable-url-rewrite-helpers=fake' '--enable-eui' '--enable-esi' '--enable-icmp' '--enable-zph-qos' '--enable-ecap' '--disable-translation' '--with-swapdir=/var/spool/squid3' '--with-logdir=/var/log/squid3' '--with-pidfile=/var/run/squid3.pid' '--with-filedescriptors=65536' '--with-large-files' '--with-default-user=proxy' '--enable-linux-netfilter' 'build_alias=i686-linux-gnu' 'CFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall' 'LDFLAGS=-Wl,-Bsymbolic-functions -fPIE -pie -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -fPIE -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security' 

我花了很多时间googling这个错误,但不能到达一个解决scheme,将configuration鱿鱼作为HTTP代理。 我如何得到这个工作?

这可能听起来令人困惑,但是您需要使用http_port指令而不是https_port来使用ssl-bump

对于http_port指令选项: http ://www.squid-cache.org/Doc/config/http_port/

ssl-bump: http : //www.squid-cache.org/Doc/config/ssl_bump/

如果在http_port上接收到CONNECT请求(或者在https_port上截获了新的连接),只要端口configuration了ssl-bump标志,就会查询该选项。 关于连接的后续数据要么被视为HTTPS,要么在没有解密的情况下在TCP级别进行解密或隧道传输,具体取决于第一次匹配的冲突“行动”。

对于ssl-bump示例: http : //wiki.squid-cache.org/ConfigExamples/Intercept/SslBumpExplicit

错误“NF getsockopt(SO_ORIGINAL_DST)”是一个NAT错误。 它与encryption无关。

由于您已将浏览器configuration为明确使用代理:

  • 你没有拦截任何东西。 使用“截取”选项是错误的,并导致NAT错误。

  • 浏览器将不会使用TLS连接到代理。 这是https_port使用错误的真正原因。

  • 浏览器将发送CONNECT消息到代理端口3127。 这些是需要“碰撞”的。

所以你需要做的仅仅是 ssl-bump设置移动到你现有的http_port行。 它应该是这样的:

 http_port 3127 ssl-bump \
    generate-host-certificates = on \
    dynamic_cert_mem_cache_size = 4MB \
    key = / etc / squid3 / example.com.private \
   证书=的/ etc / squid3 / example.com.cert

你应该做的其他事情来正确设置SSL-Bump是删除以下行:

  sslproxy_flags DONT_VERIFY_PEER
  sslproxy_cert_error全部拒绝

  always_direct全部允许

他们做得比弊端好,甚至对于debugging都没有用。

另外,将您的代理升级到最新的上游版本。 TLS和SSL-Bump都参与到快速变化的军备竞赛中,以便更好地实现安全性,并解密更好的安全性。 使用比最新版本更旧的版本可以保证以某种方式遇到问题。 Squid-3.3特别存在椭圆曲线和其他最近的密码问题,使用TLS会话恢复时会中断,不能绕过使用SNI的证书locking,生成SHA-1证书等。