免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2419 | 回复: 5

[proxy] squid限速问题 [复制链接]

论坛徽章:
0
发表于 2015-09-09 09:20 |显示全部楼层
squid和nat结合的形式做了一个服务器,为什么限速不成功代码如下


visible_hostname NAT162

#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

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


delay_pools 1     
delay_class 1 1
delay_access 1 allow all
delay_parameters 1 50000/50000 # 限制网速在50K以内
delay_initial_bucket_level 50


#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
#http_access deny all

http_access allow all

# Squid normally listens to port 3128
#http_port 3128

http_port 3128 transparent

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320

论坛徽章:
154
2022北京冬奥会纪念版徽章
日期:2015-08-07 17:10:5720周年集字徽章-年
日期:2022-10-26 16:44:2015-16赛季CBA联赛之深圳
日期:2022-11-02 14:02:4515-16赛季CBA联赛之八一
日期:2022-11-28 12:07:4820周年集字徽章-20	
日期:2023-07-19 08:49:4515-16赛季CBA联赛之八一
日期:2023-11-04 19:23:5115-16赛季CBA联赛之广夏
日期:2023-12-13 18:09:34
发表于 2015-09-09 22:13 来自手机 |显示全部楼层
本帖最后由 shang2010 于 2015-09-09 22:15 编辑

对不起,限速在iptable里面实现的啊
因为nat都抽象屏蔽掉了

论坛徽章:
0
发表于 2015-09-10 10:00 |显示全部楼层
回复 2# shang2010


不明白。难道透明代理做不了限速吗?

   

论坛徽章:
154
2022北京冬奥会纪念版徽章
日期:2015-08-07 17:10:5720周年集字徽章-年
日期:2022-10-26 16:44:2015-16赛季CBA联赛之深圳
日期:2022-11-02 14:02:4515-16赛季CBA联赛之八一
日期:2022-11-28 12:07:4820周年集字徽章-20	
日期:2023-07-19 08:49:4515-16赛季CBA联赛之八一
日期:2023-11-04 19:23:5115-16赛季CBA联赛之广夏
日期:2023-12-13 18:09:34
发表于 2015-09-10 11:25 |显示全部楼层
回复 3# mengcun123


    不明白,没有研究过

squid基本不做限速,本来就是个镜像服务器的

论坛徽章:
24
天蝎座
日期:2014-05-13 18:05:59IT运维版块每日发帖之星
日期:2015-11-26 06:20:00操作系统版块每月发帖之星
日期:2015-12-02 14:57:54IT运维版块每月发帖之星
日期:2016-01-07 23:01:56IT运维版块每周发帖之星
日期:2016-01-07 23:04:2615-16赛季CBA联赛之青岛
日期:2016-01-23 07:58:272016猴年福章徽章
日期:2016-02-18 15:30:3415-16赛季CBA联赛之北控
日期:2016-03-23 14:20:06IT运维版块每日发帖之星
日期:2016-04-01 06:20:0015-16赛季CBA联赛之吉林
日期:2016-06-28 13:51:54IT运维版块每日发帖之星
日期:2016-07-01 06:20:00IT运维版块每日发帖之星
日期:2015-11-23 06:20:00
发表于 2015-09-14 11:01 |显示全部楼层
本帖最后由 woxizishen 于 2015-09-14 11:04 编辑

流量通过squid的绝对能限速,如果经过iptables里直接nat出去的话,你那个限速参数就没作用啊。不管你squid结合什么玩意nat。没经过squid出去的流量,squid他就管不到。


另外squid限速有一个过程:
笔者亲测试,这个功能完全可以胜任企业里的带宽限速功能。说不准确的用户,八成是没有测试仔细,squid进行带宽限速时候,不会因为用户使用超过他的最大限定带宽时候,就会立即把这些用户加起来的总带宽限制到最大带宽以下,他会有一个调整过程,笔者观察到squid需要一段时间后,会把带宽降低到最大带宽以下。所以既然squid开发了这个功能,有对公司带宽质量稳定性比较在乎的,还是需要开启这个功能的。笔者就打个比方,有一次公司高层开远程视频会议,就因为一个用户下载一个几GB数据,造成远程视频会议奇卡,虽然找到了这个用户,但是我们不可能每次都问题发生了再去找原因吧,所以最好的处理问题方式就是预防问题的发生,也就是俗话说的未雨绸缪。

不过如果你公司有硬件防火墙的话,就在防火墙上做就行了。有硬的就不要软,多此一举。

论坛徽章:
0
发表于 2015-09-14 13:19 |显示全部楼层
回复 5# woxizishen


领悟了,我做普通squid代理的时候的确限制的很好,限制到200k就是200k,不会有什么问题,后来做透明代理的时候, 发现了问题,现在想来的确是的。我们公司有还有一条电信线路,这条线路是不是经过防火墙的,只是通过路由上网到该线路,所以没有限制,导致经常性的卡,也没法限制客户,所以才想通过squid透明代理限速,看起来不起作用。


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP