服务器设置为代理服务器

服务器设置为代理服务器

购买一台服务器设置为代理服务器
目前购买系统为CentOS 8.2 64位

这次安装squid软件作为设置代理服务器
squid软件就不多介绍了,google下很多解释
直接讲解安装过程
1. 检测squid是否安装过
[php]rpm -qa squid[/php]
或者
[php]whereis squid[/php]
2. 没有安装的话进行安装
[php]yum install -y squid[/php]
或者
[php]dnf install -y squid[/php]
3. 安装完成后启用代理
[php]systemctl enable –now squid.service[/php]
[php]systemctl status squid.service[/php]
返回结果如下:
[php]
[root@Server-i-v4e3m1nid9 ~]# systemctl enable –now squid.service
Created symlink /etc/systemd/system/multi-user.target.wants/squid.service → /usr /lib/systemd/system/squid.service.
[root@Server-i-v4e3m1nid9 ~]# systemctl status squid.service
● squid.service – Squid caching proxy
Loaded: loaded (/usr/lib/systemd/system/squid.service; enabled; vendor prese>
Active: active (running) since Mon 2021-02-08 15:20:41 CST; 28s ago
Docs: man:squid(8)
Process: 2591 ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF (code=exit>
Process: 2585 ExecStartPre=/usr/libexec/squid/cache_swap.sh (code=exited, sta>
Main PID: 2592 (squid)
Tasks: 3 (limit: 23978)
Memory: 14.3M
CGroup: /system.slice/squid.service
├─2592 /usr/sbin/squid -f /etc/squid/squid.conf
├─2594 (squid-1) –kid squid-1 -f /etc/squid/squid.conf
└─2595 (logfile-daemon) /var/log/squid/access.log

Feb 08 15:20:41 Server-i-v4e3m1nid9 systemd[1]: Starting Squid caching proxy…
Feb 08 15:20:41 Server-i-v4e3m1nid9 systemd[1]: Started Squid caching proxy.
Feb 08 15:20:41 Server-i-v4e3m1nid9 squid[2592]: Squid Parent: will start 1 kids
Feb 08 15:20:41 Server-i-v4e3m1nid9 squid[2592]: Squid Parent: (squid-1) proces>
lines 1-18/18 (END)…skipping…
● squid.service – Squid caching proxy
Loaded: loaded (/usr/lib/systemd/system/squid.service; enabled; vendor preset: disabl>
Active: active (running) since Mon 2021-02-08 15:20:41 CST; 28s ago
Docs: man:squid(8)
Process: 2591 ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF (code=exited, statu>
Process: 2585 ExecStartPre=/usr/libexec/squid/cache_swap.sh (code=exited, status=0/SUC>
Main PID: 2592 (squid)
Tasks: 3 (limit: 23978)
Memory: 14.3M
CGroup: /system.slice/squid.service
├─2592 /usr/sbin/squid -f /etc/squid/squid.conf
├─2594 (squid-1) –kid squid-1 -f /etc/squid/squid.conf
└─2595 (logfile-daemon) /var/log/squid/access.log

Feb 08 15:20:41 Server-i-v4e3m1nid9 systemd[1]: Starting Squid caching proxy…
Feb 08 15:20:41 Server-i-v4e3m1nid9 systemd[1]: Started Squid caching proxy.
Feb 08 15:20:41 Server-i-v4e3m1nid9 squid[2592]: Squid Parent: will start 1 kids
Feb 08 15:20:41 Server-i-v4e3m1nid9 squid[2592]: Squid Parent: (squid-1) process 2594 st>
[/php]

4. 好后看下防火墙是否开启,有开启的话设置允许squid代理服务
[php]firewall-cmd –permanent –add-service=squid[/php]
[php]firewall-cmd –reload[/php]

5. 进入配置文件目录
[php]cd /etc/squid/[/php]
编辑配置文件,允许所有ip访问:
[php]
$ vim squid.conf

http_port 3228 # 修改端口,默认为 3128
http_access allow all # 添加 ,为允许所有ip
[/php]
保存后可以检查配置文件是否有误:
[php]squid -k parse #配置文件解析日志中,没有出现ERROR 就没有问题[/php]

6. 重启squid服务
[php]systemctl restart squid[/php]

查看监听端口
[php]netstat -lnpt[/php]
如果有出现squid的监听端口就正常了

来源地址有参考 https://www.cnblogs.com/lianglab/p/14152729.html

发表评论

© 2022. powered by PHP 个人小站