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 -I PREROUTING -s -p udp --dport 53 -j DNAT --to 8.8.8.8
iptables -t nat -I POSTROUTING -p udp --dport 53 -j SNAT --to 192.168.144.49
iptables -I 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
验证一下
root@host-192-168-145-197:~# 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
本文转自gaodi2002 51CTO博客,原文链接:http://blog.51cto.com/gaodi2002/1953459
centos7安装squid代理相关推荐
- Centos7安装Squid代理服务及配置透明代理
关于Squid的概述及传统代理的配置可以参考上篇博文:Centos 7安装Squid代理服务及构建传统代理 一.透明代理 透明代理提供的服务功能与传统代理时一致的,但是其"透明"的 ...
- CentOS7安装squid代理服务器
这里写自定义目录标题 CentOS7按症状squid代理服务器 注意 使用场景 准备 安装步骤 Windows接入代理服务器 CentOS7按症状squid代理服务器 注意 做合法公民,切勿使用代理服 ...
- centos7配置squid代理(透明代理)
squid透明代理 实验材料 这里只是先详细的阐述,后面实验环境配置我会详细讲 一台centos7配置squid服务 添加一块网卡 vm1 网卡IP 192.168.100.102 模拟内网 vm2 ...
- Centos7上配置安装Squid代理(主动代理,与透明代理)
安装环境:Centos7,Windows7 centos7上安装好squid服务 centos7:172.16.0.100/24(nat),192.168.0.2/24(仅主机) windows:19 ...
- CentOS7安装nginx 代理vsftp服务器
1.安装gcc环境 yum install gcc-c++ -y 2.安装pcre库 yum install -y pcre pcre-devel 3.安装zlib库 yum install -y z ...
- Centos 7安装Squid代理服务及构建传统代理
博文大纲 一.Squid服务概述 二.安装及运行控制 一.Squid服务概述 作为应用层的代理服务软件,Squid主要提供缓存加速.应用层过滤控制的功能. 1.代理的工作机制 当客户机通过代理来请求W ...
- Centos7配置 yum代理
Centos7 下配置yum代理 1.应用场景 某些应用场景中,Linux服务器需要通过yum安装应用的包,但是这些Linux服务器可能不能连接到外网,但是内部也没有对应的yum服务器,这个时候,找一 ...
- CentOS 7安装squid代理服务器
Squid,一个高性能的代理缓存服务器,支持FTP.gopher.HTTP协议. Squid,一个缓存Internet 数据的软件,其接收用户的下载申请(作为代理服务器),并自动处理所下载的数据,并返 ...
- Centos7搭建Squid代理服务器
Centos7搭建Squid代理服务器 sumu's home 1.无需验证版----http 1.1 安装 yum install squid 1.2 修改配置文件 打开文件: vim /etc/s ...
最新文章
- 华为任正非:5G只是将来支撑人工智能存在的工具
- Java多线程编程模式实战指南(三):Two-phase Termination模式--转载
- Apache Beam欲通过uber api获取大数据
- window document
- 声明式编程与函数式编程_实用程序类与函数式编程无关
- 开发经验分享_06_前端开发技巧
- 64位centos下QQ无法输入中文只能输入英文
- nba2k online名字大全
- matplotlib之pyplot模块之标题(title()和suptitle())
- 快递单号全部查询,物流信息如何快速导出
- 怎么在php中设置收藏按钮,如何在ecshop首页给商品加入立即购买与收藏按钮
- 硬盘计算机类比推理,2019年国家公务员考试每日一练:类比推理(15)
- 高光谱遥感图像处理(14)-----ENVI使用教程之监督分类与非监督分类
- matlab预测缺失,matlab数据缺失预测
- MyBatis Plus实现动态字段排序
- 越分享越富有,给即是得,因为它符合能量流动的基本法则
- 软件工程实训有必要吗_软件工程实验(四个实验)
- 计算机应用基础教学改革参考文献,关于计算机应用基础论文范文资料 与高职院校计算机应用基础教学改革片有关论文参考文献...
- android区域和gynoid区域,甲状腺功能正常的2型糖尿病患者甲状腺激素与体脂分布的相关性研究-内科学(内分泌)专业论文.docx...
- mysql移植海思_nniefacelib是一个在海思35xx系列芯片上运行的人脸算法库