Linux网络代理服务器搭建及使用

  • 测试环境:
  1. 代理服务器:centos 7
  2. 使用代理的客户端:win 10
  • 搭建代理服务器

centos安装代理软件:squid

yum install squid -y
yum install httpd-tools -y

创建账户密码文件

mkdir /etc/squid/
htpasswd -cd /etc/squid/passwords your_username
#提示输入密码,比如输入!@#$%- -!gagaga
ok
#按ctrl+c退出

接下来重中之重,修改配置文件,首先打开配置文件(也可用vi)

vim /etc/squid/squid.conf

因为要是验证用户名密码才能使用我们的代理服务器,所以这里要在最后一行增加很多很多行- -,如下。

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwords
acl auth_user proxy_auth REQUIRED
http_access allow auth_user

cache_mem 64 MB
maximum_object_size 4 MB
minimum_object_size 0 KB
maximum_object_size_in_memory 4096 KB
cache_dir ufs /var/spool/squid 100 16 256
cache_log /var/log/squid/cache.log
access_log /var/log/squid/access.log
logfile_rotate 60
cache_swap_high 95
cache_swap_low 90

# Hide client ip #
forwarded_for delete

# Deny request for original source of a request
follow_x_forwarded_for deny all

# See below 
request_header_access X-Forwarded-For deny all
request_header_access Via deny all

http_port 0.0.0.0:(your port不要复制粘贴哦!)
visible_hostname squid.packet-pushers.net

记得要注释这些行

#http_access allow localnet
#http_access allow localhost
类似这些的东东

作为IT人员,我们严谨的做一下“单元测试”,看看配置文件有没有问题,终端输入指令:squid -k parse

如果没问题是不会报错的,如下

2020/03/20 14:23:12| Startup: Initializing Authentication Schemes ...
2020/03/20 14:23:12| Startup: Initialized Authentication Scheme 'basic'
2020/03/20 14:23:12| Startup: Initialized Authentication Scheme 'digest'
2020/03/20 14:23:12| Startup: Initialized Authentication Scheme 'negotiate'
2020/03/20 14:23:12| Startup: Initialized Authentication Scheme 'ntlm'
2020/03/20 14:23:12| Startup: Initialized Authentication.
……#省略了n行- -

OK,既然没问题,那就开启代理服务器吧!

#(停止为stop) 
systemctl start squid.service
#开机自启动
systemctl enable squid.service
  • 客户端使用代理服务器

打开浏览器的internet属性选项,如下设置之后就可以使用代理服务器上网喽(当然还会弹出窗口,让您输入用户名密码)

  • 4
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值