squid代理安装使用
young / / / 阅读量

安装

直接yum安装就行 cento6 7 相同

yum install squid -y

配置

配置主要是修改/etc/squid/squid.conf文件:

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 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
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 deny all
# 修改监听地址为本机IP
http_port 10.196.11.68:3128
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 .       0   20% 4320
# 配置代理日志路径 目录需自己创建 且squid 用户有权限
cache_access_log /web/logs/squid/access.log
cache_log /web/logs/squid/cache.log
cache_store_log /web/logs/squid/store.log
logfile_rotate 7

启动

# centos6
service squid start
# centos7
systemctl start squid  

使用代理

Squid服务器的IP为10.196.11.68.

Yum代理

# 修改 /etc/yum.conf
proxy=http://10.196.11.68:3128

wget代理

# 修改 /etc/wgetrc
http_proxy=http://10.196.11.68:3128
https_proxy=http://10.196.11.68:3128
ftp_proxy=http://10.196.11.68:3128

curl代理

# 修改 /etc/profile(所有用户) 或 ~/.bashrc(当前用户)
alias curl="curl -x 10.196.11.68:3128"

全局代理

# 修改 /etc/profile(所有用户) 或 ~/.bashrc(当前用户)
http_proxy=http://10.196.11.68:3128
https_proxy=http://10.196.11.68:3128
ftp_proxy=http://10.196.11.68:3128
export http_proxyexport https_proxyexport ftp_proxy
支付宝捐赠
请使用支付宝扫一扫进行捐赠
微信捐赠
请使用微信扫一扫进行赞赏
有 0 篇文章