美文网首页
squid正向代理

squid正向代理

作者: 老肖 | 来源:发表于2019-05-06 16:04 被阅读0次

内外网环境,做了网络隔离,只有一台机器能够访问外网。
故在该机器上配置代理服务器,进行代理转发。
之前使用Nginx,但是发现nginx支持不了https的请求 (强行支持也行,需要装一些额外包,源码编译,没必要折腾)

这里记录下一个Squid的快速配置安装

安装

可以采用多种方式安装。装好后,一般在/usr/sbin/squid 默认配置文件是:/etc/squid/squid.conf

yum install squid

修改配置文件

如果没有root权限,建议就在自己的目录建一个squid.conf
copy一个下面的demo。 (这个是从默认的/etc/squid/squid.conf里面复制出来的。)

一般情况下只需要修改下,
服务端口 http_port: 10000
日志文件路径之类的。

如果没有root权限,记得把里面的log路径,pid路径修改下。

#
# Recommended minimum configuration:
#

# Squid normally listens to port 3128
http_port 10000  

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80      # http
acl Safe_ports port 21      # ftp
acl Safe_ports port 443     # https
acl Safe_ports port 70      # gopher
acl Safe_ports port 210     # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280     # http-mgmt
acl Safe_ports port 488     # gss-http
acl Safe_ports port 591     # filemaker
acl Safe_ports port 777     # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all



# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid
cache_mem 32 MB
cache_dir aufs /home/wxadmin/app/squid/cache/ 1024 16 256
access_log /home/wxadmin/app/squid/log/access.log
cache_log  /home/wxadmin/app/squid/log/cache.log
pid_filename /home/wxadmin/app/squid/squid.pid

#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern ^gopher:    1440    0%  1440
refresh_pattern -i (/cgi-bin/|\?) 0 0%  0
refresh_pattern .       0   20% 4320

初始化/启动/停止

squid需要进行初始化才能使用。
-f 参数指定自定义配置文件。
一些常用命令。

#初始化
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf -z
# 开始
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf start
# 重启
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf restart
# 关闭
/usr/sbin/squid -f /home/wxadmin/app/squid/squid.conf -k shutdown

检查

检查端口,是否10000端口在服务。

netstat -lnp

检查是否配置成功

curl -x 127.0.0.1:10000 https://www.baidu.com

相关文章

  • Squid正向代理

    Squid简介: 代理服务器是目前网络中常见的服务器之一,它可以提供文件缓存、复制和地址过滤等服务,充分利用有限的...

  • Squid正向代理

    简介 正向代理语义上更侧重于,让代理服务器去帮忙请求某个网址。让代理服务器去帮忙访问qq,baidu这些网站等。在...

  • squid正向代理

    内外网环境,做了网络隔离,只有一台机器能够访问外网。故在该机器上配置代理服务器,进行代理转发。之前使用Nginx,...

  • ubuntu 正向代理

    使用Squid设置正向代理 安装Squid 编辑配置文件 注释下列配置 添加以下配置,允许所有的HTTP访问 配置...

  • Squid详解

    由于最近要对公司网络进行优化,经过研究使用squid对网络进行正向代理来增加速度. squid下载地址 一、squ...

  • Linux使用squid搭建自己专属的http/https代理服

    使用squid搭建自己专属的http/https正向代理服务器此方法相较于Nginx正向代理速度较慢些 还有一种t...

  • Squid使用SSLBump正向代理

    背景 最近需要使用nodeJs访问一个历史久远的网站,那个网站的服务器证书是错误的,且使用的协议是TLSv1.0。...

  • 在阿里云服务器内网下的NodeJS的代理设置

    ECS的内网机器是无法连接外网,所以考虑使用外网机器作为代理采用squid做正向代理缓存服务 首先确认内网ECS的...

  • Linux就该这么学 | 第16章 部署代理缓存服务

    第16章:使用 Squid 部署代理缓存服务 本章学习内容有:介绍代理服务的原理及其作用;介绍 Squid 服务程...

  • Squid透明代理-多公网IP指定出口IP

    什么是Squid? "Squid是一个高性能的代理缓存服务器,Squid支持FTP、gopher、HTTPS和HT...

网友评论

      本文标题:squid正向代理

      本文链接:https://www.haomeiwen.com/subject/crcdoqtx.html