AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 502054
Accepted
ALex_hha
ALex_hha
Asked: 2013-04-24 11:53:33 +0800 CST2013-04-24 11:53:33 +0800 CST 2013-04-24 11:53:33 +0800 CST

鱿鱼:无法连接到具有 tcp_outgoing_address 的对等体

  • 772

我遇到了配置两个鱿鱼服务器的问题。我有以下方案 -

在此处输入图像描述

主要思想是通过父squid从rackspace和amazon下载所有文件,并将所有文件存储在他的缓存中。

在 main_squid 服务器上配置了 PBR(iptables + ip 路由)。所有数据包都通过接收请求的相同通道

# ip ru sh
0:      from all lookup local
1000:   from all fwmark 0x3e8 lookup ISP1
2000:   from all fwmark 0x7d0 lookup ISP2
3011:   from all fwmark 0xbc3 lookup ISP3
32762:  from xxx.xxx.xxx.62 lookup ISP1
32763:  from yyy.yyy.yyy.239 lookup ISP2
32764:  from zzz.zzz.zzz.10 lookup ISP3
32766:  from all lookup main
32767:  from all lookup default

main_squid squid.conf http_port 192.168.210.1:3128 透明

cache_peer 192.168.220.2 sibling 3128 3130
dead_peer_timeout 5 seconds

acl AMAZON dstdom_regex -i (.*)s3\.amazonaws\.com
cache_peer_access 192.168.220.2 allow AMAZON

acl RACKSPACE dstdom_regex -i (.*)rackcdn\.com
cache_peer_access 192.168.220.2 allow RACKSPACE

url_rewrite_program /usr/bin/squidguard
url_rewrite_children 32

cache_dir null /tmp
cache_store_log none
cache deny all

acl local_net src 192.168.0.0/16
http_access allow local_net

parent_squid squid.conf

http_port 192.168.220.2:3128
acl main_squid src 192.168.220.1

http_access allow main_squid
http_access allow manager localhost
http_access allow manager main_squid

icp_access allow main_squid

cache_mem 30 GB
maximum_object_size_in_memory 128 MB
cache_dir aufs /squid 400000 16 256
minimum_object_size 16384 KB
maximum_object_size 1024 MB
cache_swap_low 93
cache_swap_high 98

acl PSD urlpath_regex -i \.psd$
cache allow PSD

acl ZIP urlpath_regex -i \.zip$
cache allow ZIP

acl OTHER url_regex -i ^http://*
cache deny OTHER

refresh_pattern \.psd$ 2592000 100 2592000 override-lastmod
override-expire ignore-reload ignore-no-cache
refresh_pattern \.zip$ 2592000 100 2592000 override-lastmod
override-expire ignore-reload ignore-no-cache

一切正常,直到我取消对 main_squid 以下行的注释

tcp_outgoing_address yyy.yyy.yyy.239

当我尝试从亚马逊下载任何 zip 文件时,我在 cache.log 中看到以下消息

2013/04/22 01:00:41| TCP connection to 192.168.220.2/3128 failed

如果我在 yyy.yyy.yyy.239 上运行 tcpdump,我会看到 main_squid 试图通过外部接口连接到父级但没有成功。

所以我的问题。我如何配置 main_squid,即使配置了 tcp_outgoing_address 选项,它也可以连接到父级?

聚苯乙烯

# squid -v
Squid Cache: Version 2.6.STABLE21
configure options:  '--host=x86_64-unknown-linux-gnu'
'--build=x86_64-unknown-linux-gnu' '--program-prefix=' '--prefix=/usr'
'--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin'
'--sysconfdir=/etc' '--includedir=/usr/include' '--libdir=/usr/lib64'
'--libexecdir=/usr/libexec' '--sharedstatedir=/var/lib'
'--mandir=/usr/share/man' '--infodir=/usr/share/info'
'--exec_prefix=/usr' '--bindir=/usr/sbin'
'--libexecdir=/usr/lib64/squid' '--localstatedir=/var'
'--datadir=/usr/share' '--sysconfdir=/etc/squid' '--enable-arp-acl'
'--enable-epoll' '--enable-snmp' '--enable-removal-policies=heap,lru'
'--enable-storeio=aufs,coss,diskd,null,ufs' '--enable-ssl'
'--with-openssl=/usr/kerberos' '--enable-delay-pools'
'--enable-linux-netfilter' '--with-pthreads'
'--enable-ntlm-auth-helpers=SMB,fakeauth'
'--enable-external-acl-helpers=ip_user,ldap_group,unix_group,wbinfo_group'
'--enable-auth=basic,digest,ntlm,negotiate'
'--enable-negotiate-auth-helpers=squid_kerb_auth'
'--enable-digest-auth-helpers=password'
'--with-winbind-auth-challenge' '--enable-useragent-log'
'--enable-referer-log' '--disable-dependency-tracking'
'--enable-cachemgr-hostname=localhost' '--enable-underscores'
'--enable-basic-auth-helpers=LDAP,MSNT,NCSA,PAM,SMB,YP,getpwnam,multi-domain-NTLM,SASL'
'--enable-cache-digests' '--enable-ident-lookups'
'--enable-follow-x-forwarded-for' '--enable-wccpv2'
'--enable-fd-config' '--with-maxfd=16384'
'build_alias=x86_64-unknown-linux-gnu'
'host_alias=x86_64-unknown-linux-gnu' 'CFLAGS=-D_FORTIFY_SOURCE=2
-fPIE -Os -g -pipe -fsigned-char' 'LDFLAGS=-pie'

任何帮助将不胜感激

linux
  • 2 2 个回答
  • 5505 Views

2 个回答

  • Voted
  1. skarap
    2013-05-10T12:19:13+08:002013-05-10T12:19:13+08:00

    查看 squid 的tcp_outgoing_address 文档

    您可以使用 acl 来限制tcp_outgoing_address. 将以下内容添加到 main_squid 配置中

    acl parent_squid dst 192.168.220.2/32
    tcp_outgoing_address 192.168.220.1 parent_squid
    tcp_outgoing_address yyy.yyy.yyy.239 !parent_squid
    

    但它主要是未使用的功能,有很多错误(我已经看到它在某些情况下会导致 squid 崩溃)。我建议使用 iptables 来强制使用正确的接口/ip。这样的事情应该工作

    iptables -t nat -A PREROUTING -d 192.168.220.2/32 -j SNAT --to 192.168.220.1
    
    • 0
  2. Best Answer
    ALex_hha
    2013-05-26T10:26:35+08:002013-05-26T10:26:35+08:00

    如果有人感兴趣,下面我添加了工作配置文件(主/父鱿鱼)

    主鱿鱼(192.168.220.1)配置文件

    acl local_net src 192.168.0.0/16
    acl parent_peer peername PARENT_PEER
    acl parent_squid dst 192.168.220.2
    
    acl FILE_TO_CACHE urlpath_regex \.(zip|iso|rar)$
    acl STORAGE dstdomain storage.example.net
    
    http_port 192.168.220.1:3128 intercept
    icp_port 3130
    
    cache_peer 192.168.220.2 parent 3128 3130 name=PARENT_PEER connect-timeout=7 proxy-only
    cache_peer_access PARENT_PEER allow STORAGE FILE_TO_CACHE
    
    # to connect to parent via internal interface
    tcp_outgoing_address 192.168.220.1 parent_peer
    
    # to properly get cache digest from parent
    tcp_outgoing_address 192.168.220.1 parent_squid
    
    # sent all other packets via ISP2
    tcp_outgoing_address yyy.yyy.yyy.239 local_net
    

    父鱿鱼(192.168.220.2)配置文件

    acl main_squid src 192.168.220.1
    acl FILE_TO_CACHE urlpath_regex -i \.(zip|iso|rar)$
    
    cache allow FILE_TO_CACHE
    cache deny all
    
    http_access allow main_squid
    http_access allow localhost
    http_access deny all
    
    icp_port 3130
    icp_access allow main_squid
    icp_access deny all
    
    http_port 192.168.220.2:3128
    
    cache_mem 12 GB
    maximum_object_size_in_memory 64 MB
    minimum_object_size 16384 KB
    maximum_object_size 1024 MB
    
    cache_swap_low 93
    cache_swap_high 98
    
    refresh_pattern \.iso$ 129600 100 129600 override-lastmod override-expire ignore-reload
    refresh_pattern \.zip$ 129600 100 129600 override-lastmod override-expire ignore-reload
    refresh_pattern \.rar$ 129600 100 129600 override-lastmod override-expire ignore-reload
    
    cache_effective_user squid
    cache_effective_group squid
    
    • 0

相关问题

  • Linux 主机到主机迁移

  • 如何在 Linux 机器上找到有关硬件的详细信息?

  • 如何在 Linux 下监控每个进程的网络 I/O 使用情况?

  • 在 RHEL4 上修改 CUPS 中的现有打印机设置

  • 为本地网络中的名称解析添加自定义 dns 条目

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve