部署正向代理squid

7 篇文章 0 订阅
6 篇文章 0 订阅

之前在服务端一致使用NGINX做反向代理。 方向代理隐藏了backend的WEB服务器, 起到了负载均衡,冗余等作用。
对于客户端来说, 隐藏了后面的WEB代理,客户端认为反向代理的IP即是WEB服务器。

最近出现了一种情况, 使用反向代理,并不能工作,开始考虑部署一个正向的代理。

                              VPN
    Internal_Server1   <------------------->   External_Server2
    
    

环境是这样的, Internal_Server1我司的服务器, External_Server2是其他公司的服务器。
Internal_Server1和External_Server2 之间采用VPN连接。 我司只有Internal_Server1能够与External_Server2互通。
External_Server2 上部署了一个WEB站点(通过域名访问www.internal.guully.com), 我司在Internal_Server1上访问是没问题的。

现在想在 Internal_Server1部署一个代理服务器,使得我司其他的PC能够通过Internal_Server1代理访问External_Server2。

两种方式:

1, Internal_Server1 上部署NGINX作为一个反向代理, upstream 映射到External_Server2. 这样PC通过访问Internal_Server1的IP地址来访问External_Server2
    发现有些功能不能正常工作,比如用户登录,功能不能正常使用。
    后来调试发现, 某些前端JS直接使用了 www.internal.guully.com,调用了http json接口, 在其他的PC上是不能访问到www.internal.guully.com
    所有功能不能正常工作。
    
    通过chrome WEB调试发现js的调试错误。
    Failed to load resource: net::ERR_NAME_NOT_RESOLVE  etcqz.internal.zgglyun.com/api/json:1
    因为WEB是其他公司开发的,我们并没有权限修改, 所以反向代理这种访问是不行的。
    
    
   
2, 正向代理, 之前没有部署过正向代理, 但是使用过,通过浏览器设置代理服务器,上网。 我们应该要的就是这样一个正向代理服务器软件。
    搜索后,发现squid是一款应用很广泛的正向代理服务器,同时也可以作为WEB缓存服务器。
    
    通过在Internal_Server1 上部署了squid,
    
    配置文件为/etc/squid/squid.conf。
    
    其中不知道为什么http_port设置成默认的3128会出现代理失败,改成13128后就可以。 还没有仔细分析。
    
    
    http_port 13128
    http_access allow localnet
    http_access allow localhost
    http_access allow all
    
    
    
    
    
    root@factory-server:/home/ansen# squid3 -k parse
2021/03/03 17:39:06| Startup: Initializing Authentication Schemes ...
2021/03/03 17:39:06| Startup: Initialized Authentication Scheme 'basic'
2021/03/03 17:39:06| Startup: Initialized Authentication Scheme 'digest'
2021/03/03 17:39:06| Startup: Initialized Authentication Scheme 'negotiate'
2021/03/03 17:39:06| Startup: Initialized Authentication Scheme 'ntlm'
2021/03/03 17:39:06| Startup: Initialized Authentication.
2021/03/03 17:39:06| Processing Configuration File: /etc/squid/squid.conf (depth 0)
2021/03/03 17:39:06| Processing: acl localnet src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
2021/03/03 17:39:06| Processing: acl localnet src 10.0.0.0/8            # RFC 1918 local private network (LAN)
2021/03/03 17:39:06| Processing: acl localnet src 100.64.0.0/10         # RFC 6598 shared address space (CGN)
2021/03/03 17:39:06| Processing: acl localnet src 169.254.0.0/16        # RFC 3927 link-local (directly plugged) machines
2021/03/03 17:39:06| Processing: acl localnet src 172.16.0.0/12         # RFC 1918 local private network (LAN)
2021/03/03 17:39:06| Processing: acl localnet src 192.168.0.0/16                # RFC 1918 local private network (LAN)
2021/03/03 17:39:06| Processing: acl localnet src fc00::/7              # RFC 4193 local private network range
2021/03/03 17:39:06| Processing: acl localnet src fe80::/10             # RFC 4291 link-local (directly plugged) machines
2021/03/03 17:39:06| Processing: acl SSL_ports port 443
2021/03/03 17:39:06| Processing: acl Safe_ports port 80         # http
2021/03/03 17:39:06| Processing: acl Safe_ports port 21         # ftp
2021/03/03 17:39:06| Processing: acl Safe_ports port 443                # https
2021/03/03 17:39:06| Processing: acl Safe_ports port 70         # gopher
2021/03/03 17:39:06| Processing: acl Safe_ports port 210                # wais
2021/03/03 17:39:06| Processing: acl Safe_ports port 1025-65535 # unregistered ports
2021/03/03 17:39:06| Processing: acl Safe_ports port 280                # http-mgmt
2021/03/03 17:39:06| Processing: acl Safe_ports port 488                # gss-http
2021/03/03 17:39:06| Processing: acl Safe_ports port 591                # filemaker
2021/03/03 17:39:06| Processing: acl Safe_ports port 777                # multiling http
2021/03/03 17:39:06| Processing: acl CONNECT method CONNECT
2021/03/03 17:39:06| Processing: http_access allow localhost manager
2021/03/03 17:39:06| Processing: http_access deny manager
2021/03/03 17:39:06| Processing: include /etc/squid/conf.d/*
2021/03/03 17:39:06| Processing Configuration File: /etc/squid/conf.d/debian.conf (depth 1)
2021/03/03 17:39:06| Processing: logfile_rotate 0
2021/03/03 17:39:06| Processing: http_access allow localnet
2021/03/03 17:39:06| Processing: http_access allow localhost
2021/03/03 17:39:06| Processing: http_access allow all
2021/03/03 17:39:06| Processing: http_port 13128
2021/03/03 17:39:06| Processing: coredump_dir /var/spool/squid
2021/03/03 17:39:06| Processing: refresh_pattern ^ftp:          1440    20%     10080
2021/03/03 17:39:06| Processing: refresh_pattern ^gopher:       1440    0%      1440
2021/03/03 17:39:06| Processing: refresh_pattern -i (/cgi-bin/|\?) 0    0%      0
2021/03/03 17:39:06| Processing: refresh_pattern .              0       20%     4320
2021/03/03 17:39:06| Initializing https:// proxy context

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值