分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 技术分享

centos7下搭建高匿HTTP代理

发布时间:2023-09-06 02:28责任编辑:白小东关键词:暂无标签

一、一般适用情况
1、两台都有外网IP,一台服务器请求资源通过另外一个服务器,本文重点讲第一种。
2、两台服务器,其中一台服务器只有内网IP,另外一台服务器有公网和内网IP。

二、前提

# 确认服务器端ip_forward转发开启echo 1 > /proc/sys/net/ipv4/ip_forwardip_forward需要设定为1sysctl -a |grep -w ip_forwardnet.ipv4.ip_forward = 1

客户端配置

export https_proxy=http://服务端内网ip:3128

三、下载

centosyum install squidubuntusudo apt-get install squid3  

修改配置文件

vim /etc/squid/squid.conf ?#修改配置文件#允许的客户端ipacl allcomputers src 0.0.0.0/0.0.0.0#配置用户名密码,后面会生成passwords文件auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/passwordsauth_param basic realm proxyacl authenticated proxy_auth REQUIREDhttp_access allow authenticated allcomputer

找到http_access deny all并注释掉

#http_access deny all

最好修改一下默认的3128端口,因为这个端口是默认的,很容易被网络上的代理爬虫探测到。

http_port 8828

用户名密码认证(如果没有htpasswd命令需要下载)

网络上有很多专门爬免认证的代理的爬虫,如果我们自己搭建的代理服务器不加认证的话,会被这些爬虫探测到然后沦为了免费代理。使用htpasswd来创建passwords文件,htpasswd命令在软件包apache2-utils中sudo htpasswd -c -d /etc/squid3/passwords 自定义用户名sudo chmod o+r /etc/squid3/passwords#centos7systemctl restart squid.service#centos6sudo service squid3 start或者etc/init.d/squid start加入全局环境变量 将我们的代理配置上:vim ?/etc/profile ?#(注意备份)#export http_proxy="http://用户名:密码@代理IP:代理端口"export http_proxy="http://xxxx:xxxxxxxx@172.21.0.14:8888"#在客户端验证curl -l "http://www.baidu.com"
#在服务端查看日志squid3的访问日志文件在/var/log/squid3/access.logtail -f /var/log/squid3/access.log[root@VM_0_14_centos ~]# tailf /var/log/squid/access.log 1546068808.417 ???174 172.21.0.10 TCP_MISS/502 4163 GET http://www.abc.com/ - HIER_DIRECT/199.181.132.250 text/html1546068810.082 ????11 172.21.0.10 TCP_MISS/502 4163 GET http://www.abc.com/ - HIER_DIRECT/199.181.132.250 text/html

centos7下搭建高匿HTTP代理

原文地址:https://www.cnblogs.com/zhaojingyu/p/10197411.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved