centos7安装squid代理

局域网只有一台服务器可以上互联网,其他机器需要使用代理上网,windows下可以用ccproxy,linux建议使用squid(dns解析需要配合iptables)

1、安装squid

yum install squid.x86_64

2、配置squid配置文件。

vi /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 允许192.168.0.0/16网段

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

# And finally deny all other access to this proxy

http_access deny all

# Squid normally listens to port 3128   端口修改为808端口

http_port 808

# 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:144020%10080

refresh_pattern ^gopher:14400%1440

refresh_pattern -i (/cgi-bin/|\?) 00%0

refresh_pattern .020%4320

到这里squid就配置完了。

由于客户端pc的dns解析都没有权限,所以还要把客户端的dns解析也由squid服务器这台主机转发出去。

1) echo "1" > /proc/sys/net/ipv4/ip_forward

2)iptables 配置

iptables -t nat -A PREROUTING -s -p udp --dport 53 -j DNAT --to 8.8.8.8

iptables -t nat -A POSTROUTING -p udp --dport 53 -j SNAT --to 192.168.144.49

iptables -A FORWARD -j ACCEPT

客户端配置

export http_proxy=http://192.168.144.49:808

export https_proxy=https://192.168.144.49:808

客户端配置dns

chattr -i /etc/resolv.conf  (ubuntu)

vi /etc/resolv.conf

nameserver 192.168.144.49

验证一下

[email protected]:~# ping www.sina.com

PING wwwus.sina.com (66.102.251.33) 56(84) bytes of data.

ok,dns可以用了。

curl www.sina.com

返回一大串代理,OK,代理配置成功了。

https的配置需要生成证书,可以参考以下文章。

http://www.linuxidc.com/Linux/2017-02/140398.htm

时间: 2024-08-09 02:21:11

centos7安装squid代理的相关文章

使用CentOS7配置Squid代理

其实之前配过一个squid,只是由于太懒,网上随便搜了一个教程,用了默认端口并且没有添加用户认证.某天不幸的被爬虫扫到,被用来发了半个月的垃圾邮件..直到有一天登录邮箱,看到了一大坨警告邮件,才意识到问题的严重.惊了个呆之后,赶紧重配一遍-.- 我这里是用squid配置了一个带用户认证的普通代理. 安装 安装过程十分简便,只需要安装一下squid,一条命令搞定.我这里装的是squid3.3. yum install squid rpm -qa | grep squid squid-3.3.8-1

squid 代理服务器安装配置

ubuntu16.04 安装squid代理服务器配置 本文参考 http://www.cnblogs.com/newflypig/archive/2012/09/28/2862000.html 1,删除已有squid服务 sudo apt-get autoremove squid sudo apt-get autoremove squid-common 如果出现错误 Could not get lock /var/lib/dpkg/lock 执行步骤 sudo rm -rf /var/cache

Centos7使用squid实现正向代理

正向代理:代理服务器帮助客户端(浏览器)实现互联网的访问 (1)代理服务器配置 1.安装squid yum install squid -y 2.编辑squid配置文件 #vim /etc/squid/squid.conf acl local src 192.9.191.0/24 //允许192.9.191.0/24网段内所有客户机访问代理服务器 http_access allow localnet //该记录一定要添在deny all之前 http_port 3128 3.防火墙配置 syst

自动安装squid+iptables上网代理及上网行为管理脚本(一)。

我是一个linux初学者,为了更好的学习linux,自己试着写了一些脚本,只为学习,和爱好.英语不好,为了在终端上运行,所以勉强写了几句.本脚本是为了实现自动安装squid,iptables,并实现上网行为管理的第一份脚本.后续再将iptables的规则写出来.如有错误,或更好的实现方法,请大家一起讨论,研究. script: #!/bin/bash#This script auto configure ip address , hostanem , local yum ,#and change

CentOS 7安装squid代理服务器

Squid,一个高性能的代理缓存服务器,支持FTP.gopher.HTTP协议. Squid,一个缓存Internet 数据的软件,其接收用户的下载申请(作为代理服务器),并自动处理所下载的数据,并返回给客户. 当一个用户想要下载一个主页(如米扑科技:https://mimvp.com)时,可以向Squid 发出一个申请,让Squid 代替其进行下载,然后Squid 连接所申请网站并请求该主页,接着把该主页传给用户同时保留一个备份,当别的用户申请同样的页面时,Squid 把保存的备份立即传给用户

Squid代理--经典缓存代理服务器(实现正向代理配置、ACL各种访问控制、日志分析)

Squid是Linux系统中常用的一款开源代理服务软件官方网站http://www.squid-cache.org , 可以很好的实现http.ftp.dns查询,以及ssl等应用的缓存代理. 一.Squid服务概述 缓存代理概述 1.代理的工作机制 当客户机通过代理来请求web页面时,指定的代理服务器会先检查自己的缓存,如果缓存中已经有客户机需要访问的页面,则直接将缓存中的页面反馈给请求的客户端.如果缓存中没有,则由代理服务器向web服务器发起访问请求,当获得返回的web页面后,缓存服务器首先

CentOS7上squid的部署及两种模式(4.1版本)

CentOS7上squid的部署及两种模式(4.1版本) 简介 squid是什么? Squid是一种用来缓冲Internet数据的软件.它接受来自人们需要下载的目标(object)的请求并适当地处理这些请求.也就是说,如果一个人想下载一web页面,他请求Squid为他取得这个页面.Squid随之连接到远程服务器(比如:http://squid.nlanr.net/)并向这个页面发出请求.然后,Squid显式地聚集数据到客户端机器,而且同时复制一份.当下一次有人需要同一页面时,Squid可以简单地

squid代理(一)--传统代理

Web代理的工作机制缓存网页对象,减少重复请求 代理的基本类型传统代理:适用于Internet,客户端上网需明确指定服务端IP以及端代理口透明代理:适用于共享上网网关,客户端上网不需指定服务端IP以及端代理口 使用代理的好处提高Web访问速度隐藏客户机的真实IP地址 编译安装squidcentos7服务器一枚准备好squid-3.5.23.tar.gz源码包[[email protected] ~]# tar -zxf squid-3.5.23.tar.gz[[email protected]

squid代理

1.正向代理 *作用:借助代理访问客户端访问不到的地址 *yum install squid -y  ##安装squid服务 *vim /etc/squid/squid.conf http_access allow all    ##允许所有http服务访问 # Squid nsu ormally listens to port 3128 http_port 3128   ##访问端口为3128 # Uncomment and adjust the following to add a disk