Centos 安装squid

安装squid

yum -y install squid

配置

squid 配置文件位置 /etc/squid/squid.conf, 如果没有找到,就自己创建一个。


Recommended minimum configuration:

# 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
# Recommended minimum Access Permission configuration:
#
# 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

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# 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

# auth
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm gao's squid server
auth_param basic credentialsttl 2 hours
acl myacl proxy_auth REQUIRED
http_access allow myacl

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

# Squid normally listens to port 3128
http_port 3280

# reverse https
# https_port 443 cert=/etc/squid/server.pem key=/etc/squid/server.key accel defaultsite=ec2-18-220-26-73.us-east-2.compute.amazonaws.com vhost

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

access_log /var/log/squid/access.log

# 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


启动/停止squid

systemctl start squid
systemctl stop squid

修改配置文件后的重启

1,初始化你在 squid.conf 里配置的 cache 目录
/usr/local/squid/sbin/squid -z //初始化缓存空间
如果有错误提示,请检查你的 cache目录的权限。
2,对你的squid.conf 排错,即验证 squid.conf 的 语法和配置。
/usr/local/squid/sbin/squid -k parse
如果squid.conf 有语法或配置错误,这里会返回提示你,如果没有返回,恭喜,可以尝试启动squid。

Debug

在前台启动squid,并输出启动过程。
/usr/local/squid/sbin/squid -N -d1

查看log
tail -f /var/log/squid/access.log

测试

wget -e "http_proxy=http://18.220.26.73:3128" http://www.qq.com #没有设置密码
wget -e "http_proxy=http://18.220.26.73:3128" http://www.qq.com --proxy-user=no1 --proxy-passwd=no1 # 设置了密码

参考资料

http://www.cnblogs.com/mchina/p/3812190.html

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,936评论 0 0
  • PLEASE READ THE FOLLOWING APPLE DEVELOPER PROGRAM LICENSE...
    念念不忘的阅读 13,552评论 5 6
  • 由于最近要对公司网络进行优化,经过研究使用squid对网络进行正向代理来增加速度. squid下载地址 一、squ...
    骨感冰人阅读 4,111评论 0 1
  • 为什么忘不掉前任? 文|葵七 我有个朋友的朋友,前段时间失踪了!一个如花似玉的姑娘没有和家人交代,就这么关...
    葵七i阅读 452评论 0 0
  • 2016已然过去,新的一年计划提上日程。虽说考试不是生活的全部,却也是改变命运的一条路。截至目前,国务院已取消43...
    A避风港A阅读 211评论 0 0