基于腾讯云搭建squid代理服务器
本文主要介绍下在腾讯云上搭建squid代理服务器,用于访问国外网站或者为爬虫提供代理ip,以及简单介绍下如何基于腾讯云提供的SDK,批量开启或者销毁代理服务器实例。
Squid是一个高性能的代理缓存服务器,Squid支持FTP、gopher、HTTPS和HTTP协议。和一般的代理缓存软件不同,Squid用一个单独的、非模块化的、I/O驱动的进程来处理所有的客户端请求。
下面是搭建步骤:
1、yum安装软件,并设置squid开机自启
yum install -y squid
yum install -y httpd
systemctl enable squid.service
2、创建squid代理的访问用户,并设置好密码
htpasswd -c /etc/squid/passwd 用户名
需要输入两次密码
3、配置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 # And finally deny all other access to this proxy
#http_access deny all # Squid normally listens to port 3128
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: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320 cache_mem 128 MB
maximum_object_size 16 MB
cache_dir ufs /var/spool/squid 100 16 256
access_log /var/log/squid/access.log auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid
auth_param basic credentialsttl 5 hours
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users
http_access deny all visible_hostname Squid.org
cache_mgr abingtech@163.com
systemctl restart squid.service
4、从上面的配置文件可以看出,访问端口为808,需要在云服务器的安全组中开放端口

5、可以在浏览器设置中配置代理服务器或者使用代理工具进行测试验证

为了管理方便,采用基于腾讯云SDK进行开发,我使用的是Java语言,代码很简单就不进行过多介绍,有兴趣的同学可以从码云
【https://gitee.com/abingtech/proxy.git】上pull,这里主要说明下需要注意的点:
1、申请SecretId和SecretKey
2、搭建好代理服务器后,需要在腾讯云上手工制作好镜像,作为批量创建实例的模版
3、由于腾讯云设置的每次返回列表最大limit是100,这里需要自己手工处理分页的情况
另外,云服务器实例建议买按流量计费的模式,这样不用随时可以销毁,要用启动下就行了。
基于腾讯云搭建squid代理服务器的更多相关文章
- 基于腾讯云centos简单搭建VSFTP
基于腾讯云centos7.3搭建VSFTP 环境分析: 基于vsftp服务在于云主机上,所以推荐使用FTP的PASV模式: FTP协议有两种工作方式:PORT方式和PASV方式,中文意思为主动式和被动 ...
- 【腾讯云的1001种玩法】腾讯云搭建DiscuzX论坛
版权声明:本文由艾可德原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/506828001481866457 来源:腾云阁 h ...
- linux 搭建squid代理服务器
linux 搭建squid代理服务器 实验环境: 一台linux搭建Web服务器,充当内网web服务器(同时充当内网客户端) 202.100.10.100 一台linux系统充当网关服务器,两个网卡, ...
- 基于腾讯云存储COS的ClickHouse数据冷热分层方案
一.ClickHouse简介 ClickHouse是一个用于联机分析(OLAP)的列式数据库管理系统(DBMS),支持PB级数据量的交互式分析,ClickHouse最初是为YandexMetrica ...
- 2019最新最全HUSTOJ本地及云端服务器搭建(基于腾讯云服务器)
在刚接触ACM的时候,对于那些在线测评的网站很感兴趣,就在网上搜索了一下,在Github上发现了一个有趣的项目,然后在 Github 上获取 了HUST OJ 的开源项目代码,根据网上的教程踩了无数的 ...
- 基于腾讯云的Centos6.2系统搭建Apache+Mysql+PHP开发环境
搭建环境,我肯定需要先购买腾讯云服务器的哦! 然后,我们打开SecureCRT 7.3,这是一款可以连接Linux系统的客户端工具,使用的很方便快捷,要注意的是,若你是Linux系统的就要用22端口, ...
- 基于腾讯云CLB实现K8S v1.10.1集群高可用+负载均衡
概述: 最近对K8S非常感兴趣,同时对容器的管理等方面非常出色,是一款非常开源,强大的容器管理方案,最后经过1个月的本地实验,最终决定在腾讯云平台搭建属于我们的K8S集群管理平台~ 采购之后已经在本地 ...
- 基于腾讯云Serverless的HTTP服务探活函数
本文基于 Golang 开发了一款简单易用的拨测云函数,入口函数与腾讯云 Serverless SDK 绑定.与目前腾讯云中默认的拨测函数不同的是, url-tester-func 支持非 200 响 ...
- 图片流量节省大杀器:基于腾讯云CDN的sharpP自适应图片技术实践
目前移动端运营素材大部分依赖图片,基于对图片流量更少,渲染速度更快的诉求,我们推动CDN,X5内核,即通产品部共同推出了一套业务透明,无痛接入的CDN图片优化方案:基于CDN的sharpP自适应图片无 ...
随机推荐
- AbstractQueuedSynchronizer与ReentrantLock
介绍 j.u.c包中的Lock定义了锁的行为. 而ReentrantLock是并发包下提供的一个锁的实现,它是一个可重入的.排他的锁. ReentrantLock有的属性也很简单,除了一个serial ...
- laravel 5.5 ajax返回错误信息
前段ajax发送请求 $('#reg_reg').click(function () { var formData = new FormData($( "#reg_form" )[ ...
- 解决vue页面刷新或者后退参数丢失的问题
原文链接: 点我 在商城类的项目中,会经常遇到列表数据筛选查询的情景,当要打开某一项的详情页或者暂时离开列表页,再返回(后退时),选择的筛选条件会全部丢失,辛辛苦苦选择好的条件全没了,还得重新选择,如 ...
- 图论--网络流--最大流--POJ 3281 Dining (超级源汇+限流建图+拆点建图)
Description Cows are such finicky eaters. Each cow has a preference for certain foods and drinks, an ...
- docker批量删除本地镜像和容器
长时间运行docker,每次只用docker kill去停止容器,但是从没删除过本地镜像,导致有上百个镜像在占用内存. 1.批量停止容器 docker container stop $(docker ...
- 题目分享V
题意:现在两个人做游戏,每个人刚开始都是数字1,谁赢了就能乘以k^2,输的乘以k(k可以是任意整数,每次不一定相同)现在给你最终这两个人的得分,让你判断是否有这个可能,有可能的话Yes,否则No. 分 ...
- 集成学习基础知识总结-Bagging-Boosting
理论 在概率近似正确((probably approximately correct)学习框架下.一个概念是强可学习的充分必要条件是这个概念是弱可学习(仅比随机猜测稍好). 要求 个体学习器要好而不同 ...
- C语言程序设计实验报告三
C程序设计实验报告 姓 名:张美盛 实验地点:家 实验时间:2020年3月29日 实验项目:4.3.1 If语句的应用 4.3.2 switch-case的应用 4.3.3 switch-case嵌套 ...
- C. Fountains
\(整体思路没错,但是我貌似太麻烦了.......\) \(分情况讨论\) \(Ⅰ.coin和diamond各选一个物品,这个简单\) \(Ⅱ.在coin中选两个或者在diamond选两个\) \(开 ...
- D. Beautiful Array DP
https://codeforces.com/contest/1155/problem/D 这个题目还是不会写,挺难的,最后还是lj大佬教我的. 这个题目就是要分成三段来考虑, 第一段就是不进行乘,就 ...