傅令江的光影色彩世界
留住记忆的点滴
  • 首页
  • 文学
    • 诗词鉴赏
    • 美文共读
    • 原创
  • 编程
    • php
    • asp
    • .net
    • VB
    • C/C++
    • 易语言
    • js
    • 其他
    • 逆向
  • 运维
    • windows
    • linux
  • 光影色彩
    • 电影
    • 音乐
  • 科技
    • 互联网
    • 手机
  • 生活
    • 情感
  • 微语
2月252021

使用squid搭建http和https的代理服务器设置指南

作者:傅令江   发布:2021-2-25 22:41   分类:linux   阅读:3272次   评论:0条  

我们使用nginx做过正向代理的设定,但是如果希望支持https的话,直接使用nginx则较为困难,而使用在这方面术业有专攻的squid则要简单的多。这篇文章用于记录在centos7上安装和设定squid3.5来实现http和https的步骤。

机器配置

[root@liumiaocn ~]# uname -a Linux mail.163.com 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@liumiaocn ~]#  [root@liumiaocn ~]# cat /etc/redhat-release  CentOS Linux release 7.3.1611 (Core) [root@liumiaocn ~]#

安装squid

安装命令: yum install squid

确认版本

版本确认: rpm -qa |grep squid

[root@liumiaocn ~]# rpm -qa |grep squid squid-migration-script-3.5.20-12.el7.x86_64
squid-3.5.20-12.el7.x86_64 [root@liumiaocn ~]#

确认ip_forward

ip_forward需要设定为1,缺省centos已设定,详细如下:

[root@liumiaocn ~]# sysctl -a |grep -w ip_forward net.ipv4.ip_forward = 1 [root@liumiaocn ~]#

修改设定文件

修改前

[root@liumiaocn ~]# grep -n 'http_access deny all' /etc/squid/squid.conf 56:http_access deny all [root@liumiaocn ~]#

修改后

[root@liumiaocn ~]# grep -n http /etc/squid/squid.conf |grep -w all 56:http_access allow all [root@liumiaocn ~]#

启动squid

systemctl start squid

问题1:libSSL错误

启动squid时提示如下错误

squid: relocation error: squid: symbol SSL_set_alpn_protos, version libssl.so.10 not defined in file libssl.so.10 with link time reference

原因:未安装openssl

对应方法: yum install openssl

安装之后启动squid即可:

[root@liumiaocn ~]# systemctl start squid [root@liumiaocn ~]# systemctl status squid ● squid.service - Squid caching proxy Loaded: loaded (/usr/lib/systemd/system/squid.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2018-06-05 20:07:56 CST; 8s ago Process: 28548 ExecStart=/usr/sbin/squid $SQUID_OPTS -f $SQUID_CONF (code=exited, status=0/SUCCESS) Process: 28540 ExecStartPre=/usr/libexec/squid/cache_swap.sh (code=exited, status=0/SUCCESS) Main PID: 28551 (squid) Memory: 14.3M CGroup: /system.slice/squid.service ├─28551 /usr/sbin/squid -f /etc/squid/squid.conf ├─28553 (squid-1) -f /etc/squid/squid.conf └─28557 (logfile-daemon) /var/log/squid/access.log Jun 05 20:07:56 liumiaocn systemd[1]: Starting Squid caching proxy... Jun 05 20:07:56 liumiaocn squid[28551]: Squid Parent: will start 1 kids Jun 05 20:07:56 liumiaocn squid[28551]: Squid Parent: (squid-1) process 28553 started Jun 05 20:07:56 liumiaocn systemd[1]: Started Squid caching proxy. [root@liumiaocn ~]#

问题2:无法进行域名解析

此时发现无法使用域名只能使用ip来访问

原因:dns未配置,在squid的配置文件中添加8.8.8.8和8.8.4.4

[root@liumiaocn ~]# grep nameserver /etc/squid/squid.conf dns_nameservers 8.8.8.8 8.8.4.4 [root@liumiaocn ~]#  [root@liumiaocn ~]# systemctl restart squid [root@liumiaocn ~]#

客户端的访问

squid的缺省port为3128,在这里没有修改,在客户端使用如下方式即可访问:

http方式

export http_proxy=http://192.168.163.117:3128
curl http://www.xxx.com

https方式

export https_proxy=http://192.168.163.117:3128

curl https://www.xxx.com



打开文件/etc/profile

在文件的末端输入:

http_proxy=http://username:password@proxy_ip:port/
https_proxy=http://username:password@proxy_ip:port/
ftp_proxy=http://username:password@proxy_ip:port/
export http_proxy
export https_proxy
export ftp_proxy
3.关闭文件,命令行输入

source /etc/profile
现在可以通过代理上网喽。



例子

http_proxy=http://175.6.12.82:3128/
https_proxy=http://175.6.12.82:3128/
ftp_proxy=http://175.6.12.82:3128/
export http_proxy
export https_proxy
export ftp_proxy





本文固定链接: https://www.fulingjiang.cn/linux/155.html

blogger
该日志由 傅令江 于2021-2-25 22:41 Thursday发表在 linux 分类下。
版权所有:《傅令江的光影色彩世界》 → 《使用squid搭建http和https的代理服务器设置指南》;
除特别标注,本博客所有文章均为原创. 互联分享,尊重版权,转载请以链接形式标明本文地址;
本文标签:
上一篇::Windows客户端内网穿透工具frpc安装及使用教程
下一篇:360安全浏览器 打不开 关不掉 卸不了

热门文章

  • 兄弟二周年祭

相关文章

  • nginx反向代理增加虚拟目录
  • 设置.htaccess限制IP访问的方法
  • 利用 squid 反向代理提高网站性能
  • 405报错是什么原因_状态码405是什么错误
  • nginx中的if和else语法,变通下
取消回复

发表评论

亲,头像对么?

提交中,请稍候……


木有头像就木JJ啦!还木有头像吗?点这里申请属于你的个性Gravatar头像吧!


  • 日历

  • 存档

    • 2024年10月(1)
    • 2023年2月(1)
    • 2022年11月(1)
    • 2022年10月(10)
    • 2022年9月(13)
    • 2022年8月(2)
    • 2022年7月(14)
    • 2022年6月(2)
    • 2022年5月(8)
    • 2022年4月(7)
    • 2022年3月(13)
    • 2022年2月(2)
    • 2022年1月(9)
    • 2021年12月(2)
    • 2021年11月(4)
    • 2021年10月(2)
    • 2021年9月(6)
    • 2021年7月(4)
    • 2021年6月(3)
    • 2021年5月(3)
    • 2021年4月(11)
    • 2021年3月(13)
    • 2021年2月(2)
    • 2021年1月(1)
    • 2020年12月(1)
    • 2020年4月(5)
    • 2019年9月(1)
    • 2019年8月(1)
    • 2019年5月(3)
    • 2018年3月(1)
    • 2017年10月(1)
    • 2016年7月(1)
    • 2016年4月(1)
    • 2015年12月(1)
    • 2015年11月(3)
    • 2015年9月(1)
    • 2015年8月(10)
    • 2015年7月(1)
    • 2015年6月(1)
    • 2015年4月(1)
    • 2015年3月(3)
    • 2015年2月(8)
    • 2015年1月(4)
    • 2014年12月(1)
    • 2014年11月(27)
    • 2014年10月(13)
    • 2014年9月(14)
    • 2014年8月(26)
    • 2014年7月(21)
  • 最新评论

    • 令狐江:
      喜欢这首歌是因为可以引起共鸣!
  • 链接

    • 演讲稿网
    • Recollect
    • 演讲稿
    • 祁阳人生活网
    • 我爱演讲稿网
  • 搜索

  • 标签

      函数 自定义方法 SEO 分页 分页函数 分页方法 nginx重新的一些规则
  • 分类

    • 文学(0)
    • 编程(0)
    • 运维(0)
    • 光影色彩(0)
    • 科技(0)
    • 生活(0)
    • 诗词鉴赏(3)
    • 美文共读(1)
    • 原创(10)
    • php(111)
    • asp(1)
    • .net(0)
    • VB(0)
    • C/C++(0)
    • 易语言(0)
    • js(8)
    • 其他(9)
    • 逆向(2)
    • windows(11)
    • linux(121)
    • 电影(0)
    • 音乐(1)
    • 互联网(4)
    • 手机(0)
    • 情感(2)
  • 最新文章热门文章随机文章

    • 兄弟二周年祭
    • openai给的ionCube 解密代码,应该是老版本可以这样
    • WordPress – 5秒盾防CC(PHP通用代码)
    • 我高中最好的朋友今天猝死了-伤心得不行
    • Linux系统中 systemd-journaldCPU占用异常的解决方法
    • SVN Skipped 'xxx' -- Node remains in conflict 错误的解决办法
    • 解决Linux读写nfs共享盘速度慢的问题
    • php 获取302跳转后的地址
    • 让vsftp显示隐藏文件的办法,比如显示 .htaccess
    • 添加自签名https证书到centos系统信任的问题
    • php图片正则|preg_math|<img>标签
    • php记录日志,达到文件大小,自动新建文件
    • PHP自适应分页代码,可以灵活定制CSS样式和分页链接效果!
    • PHP邮件发送支持附件
    • php图片加水印类
Copyright © 2001-2025 傅令江的光影色彩世界. Powered by www.fulingjiang.cn ICP备案:京ICP备14015190号-5