• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

nginx 转发squid 代理

武飞扬头像
搬砖的梦先生
帮助1

1、准备

服务器 用途
192.168.0.1 nginx
192.168.0.2 squid

2、原理

nginx转发squid实际上是利用tcp实现的,http是无法实现转发squid功能的

nginx负责TCP转发的模块为stream,stream默认不安装的,需要手动添加参数:

--with-stream

3、nginx 配置

stream模块和http模块是同级的关系。

配置如下:

stream {
        server {
        ## 监听本机端口
        listen 192.168.0.1:8080; 
        proxy_connect_timeout 1s;
        proxy_timeout 3s;
        ## 转发squid端口
        proxy_pass 192.168.0.2:3128; 
}

4、客户端配置

  vim /etc/profile
  source /etc/profile
PROXY_URL="http://192.168.0.1:8080/"
NO_PROXY_ADDR="127.0.0.1,localhost,.local,.cluster.local,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16"
export http_proxy="$PROXY_URL"
export https_proxy="$PROXY_URL"
export no_proxy="$NO_PROXY_ADDR"
export HTTP_PROXY="$PROXY_URL"
export HTTPS_PROXY="$PROXY_URL"
export NO_PROXY="$NO_PROXY_ADDR"

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfkcic
系列文章
更多 icon
同类精品
更多 icon
继续加载