鱿鱼反向代理与多个WAN接口

我有以下设置:

  • 两条广域网线路,每条线路都有一个静态的公网IP,都连接到一个单独的路由器,提供两个内部networking(net1和net2)
  • 一个安装了squid 3.3.8(使用–enable-ssl编译)的Ubuntu 14.04 LTS服务器,具有两个接口,位于每个networking中,具有net1作为默认网关
  • 对于位于net1或net2中的某些服务器,squid是反向代理服务器
  • 两个在每个WAN-IP上都有Alogging的子域
  • 两台路由器上端口80和443的端口转发指向了鱿鱼服务器的相应ip

为了更好地理解: sub1.domain.tld-->WAN1--ROUTER1--net1--SERVER1 | SQUID | sub2.domain.tld-->WAN2--ROUTER2--net2--SERVER2 sub1.domain.tld-->WAN1--ROUTER1--net1--SERVER1 | SQUID | sub2.domain.tld-->WAN2--ROUTER2--net2--SERVER2

我的问题:

  • 访问从互联网sub1.domain.tld预期,也出现在access.log
  • 从互联网访问sub2.domain.tld会导致超时,日志中没有任何内容显示
  • 强制sub2.domain.tldwan1的ip通过主机 – 客户端的文件一切都按预期工作,也出现在access.log
  • 还有从eth0到eth0的切换网关(与各自的网关ip)一切都按预期工作,也出现在access.log中

似乎从鱿鱼返回的数据包总是采取默认路线。

如何解决这个问题,使两个广域网路由工作?

我尝试使用tcp_outgoing_address,但没有成功:

 tcp_outgoing_address 192.168.1.123 localnet1 tcp_outgoing_address 192.168.2.123 localnet2 

同样明确地绑定到具体的IPS并没有帮助:

 http_port 192.168.1.123:80 accel defaultsite=sub1.domain.tld https_port 192.168.1.123:443 accel cert=/etc/ssl/certs/domain.tld.crt key=/etc/ssl/private/domain.tld.key defaultsite=sub1.domain.tld http_port 192.168.2.123:80 accel defaultsite=sub2.domain.tld https_port 192.168.2.123:443 accel cert=/etc/ssl/certs/domain.tld.crt key=/etc/ssl/private/domain.tld.key defaultsite=sub2.domain.tld 

谢谢你的帮助!


这里是相应的configuration:

鱿鱼服务器的/ etc / network / interfaces

 auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.123 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 192.168.1.1 auto eth1 iface eth1 inet static address 192.168.2.123 netmask 255.255.255.0 dns-nameservers 192.168.2.1 

/etc/squid3/squid.conf

 # define some ACL aliases acl localnet1 src 192.168.1.0/24 acl localnet2 src 192.168.2.0/24 acl allsrc src all acl safeports port 80 443 acl sslports port 443 acl purge method PURGE acl connect method CONNECT acl HTTP proto HTTP acl HTTPS proto HTTPS # restrict management options http_access allow manager localhost http_access deny manager http_access allow purge localhost http_access deny purge # block non-safe ports http_access deny !safeports http_access deny CONNECT !sslports # define ports and certs http_port 80 accel defaultsite=sub1.domain.tld https_port 443 accel cert=/etc/ssl/certs/domain.tld.crt key=/etc/ssl/private/domain.tld.key defaultsite=sub1.domain.tld # define peers cache_peer 192.168.1.234 parent 443 0 proxy-only no-query no-digest originserver login=PASSTHRU connection-auth=on ssl sslflags=DONT_VERIFY_PEER front-end-https=on name=server1 cache_peer 192.168.2.234 parent 443 0 proxy-only no-query no-digest originserver login=PASSTHRU connection-auth=on ssl sslflags=DONT_VERIFY_PEER front-end-https=on name=server2 # define uris acl server1_acl url_regex -i ^https://sub1.domain.tld/*$ acl server2_acl url_regex -i ^https://sub2.domain.tld/*$ # bind peers to acls and block direct access never_direct allow server1_acl http_access allow server1_acl cache_peer_access server1 allow server1_acl never_direct allow server2_acl http_access allow server2_acl cache_peer_access server2 allow server2_acl # handle unhandled connections deny_info TCP_RESET allsrc http_access allow localnet1 http_access allow localnet2 http_access deny allsrc 

好的,发现问题:路由问题…

就像我以为所有传出的数据包都通过eth0发送。 这可以通过设置其他路线来解决:

添加新的路由表:

 echo 1 rt2 >> >> /etc/iproute2/rt_tables 

configuration新的路由:

 ip route add 192.168.2.0/24 dev eth1 src 192.168.178.123 table rt2 ip route add default via 192.168.2.1 dev eth1 table rt2 ip rule add from 192.168.2.123/32 table rt2 ip rule add to 192.168.2.123/32 table rt2 

为了使这个持久包含在eth1的/ etc / network / interfaces中

 post-up ip route add 192.168.2.0/24 dev eth1 src 192.168.178.123 table rt2 post-up ip route add default via 192.168.2.1 dev eth1 table rt2 post-up ip rule add from 192.168.2.123/32 table rt2 post-up ip rule add to 192.168.2.123/32 table rt2 

致: