免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6547 | 回复: 7
打印 上一主题 下一主题

[proxy] squid单网卡反向代理多域名问题--已解决 [复制链接]

论坛徽章:
17
2015年辞旧岁徽章
日期:2015-03-03 16:54:152017金鸡报晓
日期:2017-02-08 10:39:422017金鸡报晓
日期:2017-01-10 15:19:56JAVA
日期:2016-11-01 13:25:46C
日期:2016-10-25 16:01:4715-16赛季CBA联赛之八一
日期:2016-06-21 23:38:0815-16赛季CBA联赛之山东
日期:2016-05-12 12:49:54IT运维版块每日发帖之星
日期:2016-04-20 06:20:00IT运维版块每日发帖之星
日期:2016-03-22 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13IT运维版块每日发帖之星
日期:2015-08-25 06:20:002015亚冠之德黑兰石油
日期:2015-08-22 22:55:54
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-02-26 15:51 |只看该作者 |倒序浏览
本帖最后由 ccjsj1 于 2010-03-01 10:33 编辑

系统:centos-5.1
软件:squid-3.1.0.16.tar.bz2


192.168.1.1 开启80口,安装squid-3.1和httpd-2.2.9,外网的访问被影射到192.168.1.1的80口,安装apache-2.2.9开启81口,有www.abc.com和[url]www.cde.com[/url]网站。

192.168.1.2 开启80口,安装httpd-2.2.9,有www.bcd.com和[url]www.def.com[/url]网站。

1. 下载squid

wget --continue http://core.ring.gr.jp/archives/ ... id-3.1.0.16.tar.bz2

2. 解开squid

tar -jxf squid-3.1.0.16.tar.bz2

3. 进入目录

cd squid-3.1.0.16

4. 运行configure

./configure --prefix=/usr/local/squid-3.1 --enable-arp-acl --enable-linux-netfilter --enable-async-io=160 --enable-cache-digests --enable-underscore --enable-icmp --enable-gnuregex --enable-poll --disable-auto-local

5. 编译并安装

make && make install

6. 编辑配置文件

vi /usr/local/squid-3.1/etc/squid.conf

# 将http_access deny all 改为
http_access allow all

# Squid 服务器监听本机80 端口,支持域名和IP的虚拟主机。

http_port 80 vhost vport

# 代理到192.168.1.1主机的81口和192.168.1.2的80口
cache_peer 192.168.1.1 parent 81 0 no-query originserver name=a
cache_peer 192.168.1.2 parent 80 0 no-query originserver name=b
cache_peer 192.168.1.1 parent 81 0 no-query originserver name=c
cache_peer 192.168.1.2 parent 80 0 no-query originserver name=d

#访问的网址与相对应代理到的主机。
cache_peer_domain a http://www.abc.com
cache_peer_domain b http://www.bcd.com
cache_peer_domain c http://www.cde.com
cache_peer_domain d http://www.def.com

# 缓存目录
cache_dir ufs /usr/local/squid-3.1/var/cache 10000 16 256
cache_log /usr/local/squid-3.1/var/logs/cache.log
access_log /usr/local/squid-3.1/var/logs/access.log nobody

#缓存设置
cache_mem 1024 MB
max_open_disk_fds 0
minimum_object_size 0 KB
maximum_object_size 32 MB
maximum_object_size_in_memory 2048 KB
cache_swap_low 90
cache_swap_high 95

7. 权限设置

cd /usr/local/squid-3.1/var/ && mkdir cache

chown -R nobody {cache,logs}

8. 初始化cache目录

/usr/local/squid-3.1/squid -z

9. 启动squid

/usr/local/squid-3.1/sbin/squid

论坛徽章:
0
2 [报告]
发表于 2010-03-01 10:06 |只看该作者
不错,先顶再看。。。

论坛徽章:
0
3 [报告]
发表于 2010-03-03 11:06 |只看该作者
貌似不行啊

论坛徽章:
17
2015年辞旧岁徽章
日期:2015-03-03 16:54:152017金鸡报晓
日期:2017-02-08 10:39:422017金鸡报晓
日期:2017-01-10 15:19:56JAVA
日期:2016-11-01 13:25:46C
日期:2016-10-25 16:01:4715-16赛季CBA联赛之八一
日期:2016-06-21 23:38:0815-16赛季CBA联赛之山东
日期:2016-05-12 12:49:54IT运维版块每日发帖之星
日期:2016-04-20 06:20:00IT运维版块每日发帖之星
日期:2016-03-22 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13IT运维版块每日发帖之星
日期:2015-08-25 06:20:002015亚冠之德黑兰石油
日期:2015-08-22 22:55:54
4 [报告]
发表于 2010-03-05 13:32 |只看该作者
报什麽错了吗?做了没问题的。

论坛徽章:
0
5 [报告]
发表于 2010-03-09 09:32 |只看该作者
http_access allow all 要放到后面才行

论坛徽章:
17
2015年辞旧岁徽章
日期:2015-03-03 16:54:152017金鸡报晓
日期:2017-02-08 10:39:422017金鸡报晓
日期:2017-01-10 15:19:56JAVA
日期:2016-11-01 13:25:46C
日期:2016-10-25 16:01:4715-16赛季CBA联赛之八一
日期:2016-06-21 23:38:0815-16赛季CBA联赛之山东
日期:2016-05-12 12:49:54IT运维版块每日发帖之星
日期:2016-04-20 06:20:00IT运维版块每日发帖之星
日期:2016-03-22 06:20:00黄金圣斗士
日期:2015-11-24 10:43:13IT运维版块每日发帖之星
日期:2015-08-25 06:20:002015亚冠之德黑兰石油
日期:2015-08-22 22:55:54
6 [报告]
发表于 2010-03-20 18:47 |只看该作者
回复 5# furennan


我这个直接在原来位置改了,你的放到哪个位置了?

论坛徽章:
0
7 [报告]
发表于 2010-04-26 18:08 |只看该作者
学习了,简练通俗,喜欢~~

论坛徽章:
0
8 [报告]
发表于 2011-05-14 12:16 |只看该作者
http_port 80 vhost vport
vhost和vport在做方向代理的时候是否保持默认?
cache_peer 192.168.1.1 parent 81 0 no-query originserver name=a
这一行我在我的squid.conf里面没有找到,我直接加在后面可以么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP