squid正向代理http&https

1.1 演示环境

cat /etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

# server端ip及需求

安装squid;可以上外网;{内网+外网ip}

# client 端ip及需求

内网ip和server端内网ip在同一网端

1.2 安装squid

yum install squid -y

1.3 正向代理配置{server}

# 确认版本

rpm -qa |grep squid

squid-migration-script-3.5.20-12.el7.x86_64

squid-3.5.20-12.el7.x86_64

 

# 确认ip_forward转发开启

echo 1 > /proc/sys/net/ipv4/ip_forward

ip_forward需要设定为1

sysctl -a |grep -w ip_forward

net.ipv4.ip_forward = 1

 

# 修改配置文件

修改前

grep -n 'http_access deny all' /etc/squid/squid.conf

56:http_access deny all

修改后

grep -n http /etc/squid/squid.conf |grep -w all

56:http_access allow all

 

# 启动

systemctl start squid

# 添加防火墙规则

firewall-cmd --zone=public --add-port=3128/tcp --permanent

firewall-cmd --reload

1.4 客户端配置

1.4.1 https测试

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

curl -I https://www.baidu.com

#返回结果

    HTTP/1.1 200 OK

    Server: nginx/1.12.2

    Date: Tue, 24 Oct 2017 14:59:44 GMT

    Content-Type: text/html

    Content-Length: 277

    Connection: keep-alive

    Last-Modified: Mon, 13 Jun 2016 02:50:26 GMT

    ETag: "575e1f72-115"

    Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform

    Pragma: no-cache

    Accept-Ranges: bytes

 

1.4.2 http测试

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

curl -I http://www.baidu.com

#返回结果

    HTTP/1.1 200 OK

    Server: nginx/1.12.2

    Date: Tue, 24 Oct 2017 14:59:44 GMT

    Content-Type: text/html

    Content-Length: 277

    Connection: keep-alive

    Last-Modified: Mon, 13 Jun 2016 02:50:26 GMT

    ETag: "575e1f72-115"

    Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform

    Pragma: no-cache

    Accept-Ranges: bytes

 

1.4.3 全局配置

    # cp /etc/skel/.bash_profile /etc/skel/.bash_profile.bk

    # vim /etc/skel/.bash_profile

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

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

 

    # source /etc/skel/.bash_profile

    # env |grep http

http_proxy=http://服务端内网ip:3128

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

posted @   Hello_worlds  阅读(3316)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
点击右上角即可分享
微信分享提示