squid俗称代理,可搭建正向代理和反向代理。 正向代理是什么意思,通俗的讲,当用户访问一个网站,通过代理IP去访问这个网站,而这个网站根本不知道是当前用户去访问的。 反向代理就是用户在访问一个用户时,其实不是访问的本站网站,而是访问的是反向代理所占的ip的 用户不用知道访问的网站是什么。 正向代理搭建步骤 首先狭隘squid包再说。 yum install -y squid 这里也可以编译安装。 2.查看版本squid -v 3.编辑vim /etc/squid/squid.conf http_port 3128 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 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 SSL_ports port 443 acl Safe_ports port 80 8080 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localnet http_access allow localhost http_access allow all cache_dir aufs /data/cache 1024 16 256 (本地磁盘缓存目录) cache_mem 128 MB (缓存占用的内存大小。) hierarchy_stoplist cgi-bin ? coredump_dir /var/spool/squid refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern \.(jpg|png|gif|mp3|xml) 1440 50% 2880 ignore-reload refresh_pattern . 0 20% 4320 4.保存退出 5.mkdir /data/cache/ chown -R squid:squid /data/cache/ #squid -z 初始化 6.squid -kcheck 检查语法有没有问题。 7./etc/init.d/squid start 8.测试 在windows机器上点开浏览器,找到工具,>internet选项,>连接>局域网设置>代理服务器>输入squid机器上的Ip以及/etc/squid/squid/conf上定义的端口( http_port 3128 ) 当然也可以在linux上的机器上通过curl命令来测试 如:curl -xlocalhost:3128 http://www.baidu.com/ 如果你看到一大串,说明squid正向代理设置好了。最好是看一个图片来测试。 9.加一个小知识点 当要squid限制某些代理不能访问的网站,这要在squid.conf文件里加点东西了。 在找到: acl CONNECT method CONNECT 在其下面添加四行:比如 acl http proto HTTP acl good_domain dstdomain http_access allow http good_domain http_access deny http !good_domain 这里的意思是,只允许百度,腾讯网站才能通过代理。 10.测试随便访问一个网站比如, curl -xlocalhost:80 -I www.51cto.com/ 测试结果是403表示没问题。 反向代理搭建 把http_port 3128 改成 http_port 80 accel vhost vport cache_peer 123.125.119.147 parent 80 0 originserver name=a cache_peer 61.135.169.125 parent 80 0 originserver name=b cache_peer_domain a www.qq.com cache_peer_domain b www.baidu.com 这里a定义为腾讯,b定义为百度。 重启squid 测试同上。
squid正向代理,反向代理搭建
原创文章标签 反向代理 squid 正向代理 文章分类 运维
©著作权归作者所有:来自51CTO博客作者出VU时代的原创作品,如需转载,请与作者联系,否则将追究法律责任
上一篇:rsync模式之后台服务讲解
下一篇:给用户限制磁盘配额
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
squid正向代理反向代理
squid正向代理反向代理
squid 反向代理 -
squid详解(正向代理、透明代理、反向代理)
squid正向代理案例详解,透明代理案例详解,反向代理案例详解。通过案例理解三种代理模式
linux架构 内网 外网 缓存