AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[squid](server)

Martin Hope
Alex
Asked: 2024-02-14 16:32:12 +0800 CST

无法使用 Squid 缓存动态内容

  • 5

我正在尝试使用鱿鱼来缓存一些动态内容。内容来自诸如 之类的请求/path/{id},其中id是资源的标识符。我尝试过使用鱿鱼的配置文件,但到目前为止还没有成功。

它可以缓存“/path/resource”之类的内容,但对于动态内容不起作用。充满access.log了TCP_MISS_ABORTED.

这是我的配置文件:

#
# Recommended minimum configuration:
#

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 0.0.0.1-0.255.255.255  # RFC 1122 "this" network (LAN)
acl localnet src 10.0.0.0/8     # RFC 1918 local private network (LAN)
acl localnet src 100.64.0.0/10      # RFC 6598 shared address space (CGN)
acl localnet src 169.254.0.0/16     # RFC 3927 link-local (directly plugged) machines
acl localnet src 172.16.0.0/12      # RFC 1918 local private network (LAN)
acl localnet src 192.168.0.0/16     # RFC 1918 local private network (LAN)
acl localnet src fc00::/7           # RFC 4193 local private network range
acl localnet src fe80::/10          # RFC 4291 link-local (directly plugged) machines
acl dynamic_content urlpath_regex ^/long_text/get/[0-9]+

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

#
# 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

# This default configuration only allows localhost requests because a more
# permissive Squid installation could introduce new attack vectors into the
# network by proxying external TCP connections to unprotected services.
http_access allow localhost
http_access allow dynamic_content

# Protect web applications running on the same server as Squid. They often
# assume that only local users can access them at "localhost" ports.
http_access allow to_localhost
http_access allow all

# Squid normally listens to port 3128
http_port 3128

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

# Leave coredumps in the first cache dir
cache_mem 1000 MB
maximum_object_size 4 MB
#
# Add any of your own refresh_pattern entries above these.
#
refresh_pattern ^ftp:       1440    20% 10080
refresh_pattern .       0   20% 4320

debug_options ALL,1 33,2

此外,出于测试原因,squid 服务与发出请求的客户端以及 Web 服务器在同一台服务器上运行。

编辑:对象不大于 1.5 MB

Edit2:访问日志如下所示:

1707899048.785      6 192.168.100.150 TCP_MISS/200 12592 GET http://192.168.100.150:8080/long_text/get/113 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.793      7 192.168.100.150 TCP_MISS_ABORTED/200 8488 GET http://192.168.100.150:8080/long_text/get/1868 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.806     11 192.168.100.150 TCP_MISS_ABORTED/200 20800 GET http://192.168.100.150:8080/long_text/get/743 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.814      8 192.168.100.150 TCP_MISS_ABORTED/200 20800 GET http://192.168.100.150:8080/long_text/get/1 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.821      5 192.168.100.150 TCP_MISS_ABORTED/200 8488 GET http://192.168.100.150:8080/long_text/get/1412 - HIER_DIRECT/192.168.100.150 text/plain
1707899048.828      6 192.168.100.150 TCP_MISS_ABORTED/200 12592 GET http://192.168.100.150:8080/long_text/get/566 - HIER_DIRECT/192.168.100.150 text/plain

他们中的大多数是TCP_MISS_ABORTED,我想说只有百分之一是TCP_MISS,但我得到的不是TCP_MEM_HIT。

编辑:由网络服务器作为响应发送的完整标头:

Cache-Control: max-age=60
Content-Type: text/plain; charset=utf-8
Date: Wed, 14 Feb 2024 09:25:32 GMT
Transfer-Encoding: chunked

编辑:连续获取相同资源的日志:

1707902670.872     18 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904558.006     12 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904558.777     11 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904559.535     15 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
1707904560.233     11 127.0.0.1 TCP_MISS/200 1045060 GET http://127.0.0.1:8080/long_text/get/1 - HIER_DIRECT/127.0.0.1 text/plain
squid
  • 1 个回答
  • 53 Views
Martin Hope
ehammer
Asked: 2023-05-09 04:27:48 +0800 CST

Rsyslog 将文本添加到某些设施中的消息中

  • 6

操作系统:Debian 11 Rsyslog 版本 8.2102 Squid 版本 4.13

我试图在不通过文件的情况下远程记录 squid 日志。我在 squid.conf 中使用以下日志行作为存储日志:

cache_store_log syslog:local:6

这些存储日志出现在日志中,因此它们按预期跳过了标准日志文件。

当生成这些日志时,它们与 squid 访问日志没有有意义的区别。所以为了正确处理这些日志,我想在所有local6日志的开头添加一个字符串,比如squid-store

在 rsyslog.conf 我有以下相关行:

$template squidstore_tagged,"squid-store %msg%\n"
local6.* @192.168.3.2:1514;squidstore_tagged

*.* @192.168.3.2:1514

尽管 rsyslog 进程重新启动没有错误,并且 squid 存储日志确实到达了远程服务器,但它们没有标记为“squid-store”。然后我尝试使用此配置进行故障排除,但日志仍然到达远程服务器:

#$template squidstore_tagged,"squid-store %msg%\n"
#local6.* @192.168.3.2:1514;squidstore_tagged
local6.* /dev/null
*.* @192.168.3.2:1514

如何在远程发送之前用一些文本标记来自鱿鱼商店的日志?

squid
  • 1 个回答
  • 18 Views
Martin Hope
Thomas P
Asked: 2022-03-02 07:01:51 +0800 CST

Squid 正则表达式语法描述?

  • 0

从abuse.ch可以得到一个带有恶意软件分发 URI 的纯文本文件。我想将其用作 squid 代理的黑名单(尚不确定运行时行为)。acl aclname url_regex ...将 URI 文件转换为正则表达式文件以供使用应该不难sed,但我很难找到 squid 正则表达式语法描述来识别我必须转义的所有特殊字符。

squid
  • 1 个回答
  • 241 Views
Martin Hope
Alex G
Asked: 2022-01-26 16:25:15 +0800 CST

Squid 在调试时没有返回 http 消息体

  • -1

根据Squid 文档,何时debug_options rotate=1 ALL,9设置,squid.conf我应该看到HTTP Message Bodycache.log

但是,它没有出现。

我确实看到了所有内容,包括 HTTP 标头,但没有正文。

我什至尝试设置debug_options为11,9,但我只看到 HTTP 标头,而不是正文。

Squid 被配置为 HTTP 和 HTTPS 的透明代理。我发送的请求是 HTTPS。

任何人,请帮忙?

提交的错误:https ://bugs.squid-cache.org/show_bug.cgi?id=5194

squid
  • 1 个回答
  • 134 Views
Martin Hope
Realbitt
Asked: 2021-12-30 04:08:41 +0800 CST

为我的 VPN 用户屏蔽网站

  • 0

我的strongswan运行良好,我需要通过它的域阻止一些不良网站被VPN用户访问,我尝试了很多方法但没有运气将流量从vpn重定向到像squid这样的代理服务器,但我发现转发流量到squid它完成了由于它的网站 IP 不是域名,所以这种技术没有成功。

也许这不是strongswan生意,但任何想法都会受到欢迎。

提前致谢

linux squid strongswan
  • 2 个回答
  • 168 Views
Martin Hope
ogbofjnr
Asked: 2021-12-05 14:46:31 +0800 CST

如何将流量从 squid 重定向到 vpn?

  • 0

我有一台带有 squid 服务器和 VPN 客户端连接的 Windows 机器(这不是默认网关)

我想要的是将一些流量从 squid 重定向到我的默认以太网连接,并将一些流量重定向到 VPN。

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.100.11
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.100.1

PPP adapter vpn_conn:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 172.16.3.33
   Subnet Mask . . . . . . . . . . . : 255.255.255.255
   Default Gateway . . . . . . . . . :

鱿鱼

http_port 2003
acl  user3_acl  myport 2003
tcp_outgoing_address 172.16.3.33 user3_acl

http_port 2004
acl  user4_acl  myport 2004

2004 端口通过我的以太网适配器按预期工作,但重定向到 vpn 不起作用,

日志包含

1638648992.630     75 33.33.333.333 NONE/503 0 CONNECT docs.microsoft.com:443 - HIER_NONE/- -
vpn routing proxy squid
  • 1 个回答
  • 352 Views
Martin Hope
Rodrigo
Asked: 2021-11-02 03:56:02 +0800 CST

使用用户创建 HTTP 代理并使用 Squid 传递

  • -2

我想知道是否可以使用Squid作为具有基本身份验证的代理,例如与 cURL 一起使用:

curl -vvv "https://ifconfig.me" -x user:password@localhost:8000

其中 localhost 是 Squid 实例。

Squid 和 HTTPS 网站可以吗?

linux http squid
  • 1 个回答
  • 116 Views
Martin Hope
Tilman Schmidt
Asked: 2021-10-26 06:06:41 +0800 CST

如何调试 Squid ERR_DNS_FAIL

  • 0

我正在全球分布的多个位置管理几个在 Ubuntu 20.04LTS 上运行 Squid 4.10 的网络代理。其中一个人养成了偶尔无法访问网页的坏习惯。用户会收到一个错误页面,上面写着:

Hmmm... can't reach this page
It looks like the webpage at <URL> might be having issues,
or it may have moved permanently to a new web address.
ERR_TUNNEL_CONNECTION_FAILED

按照此邮件列表帖子中的建议添加%err_code/%err_detail到相关内容的末尾后,失败访问的 Squid access.log 条目如下所示:logformat

1635169354.239    171 10.72.1.103 NONE/503 0 CONNECT ad.360yield.com:443 - HIER_
NONE/- - ERR_DNS_FAIL/-

Squid 状态是NONE/503,错误代码和详细信息总是ERR_DNS_FAIL/-。时间戳、客户端 IP 地址和请求的 URL 当然会有所不同。

每次出现问题都会影响单个 FQDN 或极少数 FQDN,通常都来自同一组织(例如 lm.licenses.adobe.com 和 cc-api-data.adobe.io,均来自 Adob​​e。)所有其他访问继续正常工作。一个事件通常持续五到十分钟。在此期间,所有尝试访问该 FQDN 的客户端都会受到影响。在此之前和之后,相同的 FQDN 可以正常工作。受影响的 FQDN 没有明显的规律性。

一些事件伴随着如下消息:

2021/10/25 15:42:34 kid1| ipcacheParse No Address records in response to 'ad.360yield.com'

但在/var/log/squid/cache.log大多数情况下,那里没有任何记录。

我怎样才能找出那里出了什么问题?

domain-name-system squid
  • 1 个回答
  • 1308 Views
Martin Hope
theillien
Asked: 2021-06-26 14:08:29 +0800 CST

无法通过 HTTPS Squid 代理访问 HTTP 站点

  • 1

我有 Squid 4.4 和 RHEL8 上 SSL 碰撞的工作配置。不过,我发现少数没有设置 SSL 的网站(例如http://squidguard.org)无法正常工作。

我不得不使用几个不同的来源拼凑我的配置,因为似乎没有一个提供确定的方法来设置 SSL 碰撞。我可能错过了一些允许 Squid 处理 HTTP 和 HTTPS 流量的东西?

这是我在日志中看到的:

1624658033.150  59887 10.108.0.18 TCP_MISS/503 4300 GET http://squidguard.com/favicon.ico - HIER_DIRECT/3.223.115.185 text/html
1624658042.966  60608 10.108.0.18 TCP_MISS/503 4392 GET http://squidguard.com/ - HIER_DIRECT/3.223.115.185 text/html

浏览器页面上的错误说

The following error was encountered while trying to retrieve the URL: http://squidguard.com/
Connection to 3.223.115.185 failed.
The system returned: (110) Connection timed out
The remote host or network may be down. Please try the request again.

不过,远程主机或网络并未关闭。我可以在不通过代理时到达它。

我的 squid.conf:

acl vdi src 10.108.0.0/20

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

acl intermediate_fetching transaction_initiator certificate-fetching
http_access allow intermediate_fetching

http_access deny !Safe_ports

http_access allow localhost manager
http_access deny manager

http_access allow vdi

http_access deny all

http_port 0.0.0.0:3128
http_port 0.0.0.0:3129 ssl-bump cert=/etc/squid/ssl_cert/myCA.pem generate-host-certificates=on
https_port 0.0.0.0:3130 intercept ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=20MB cert=/etc/squid/ssl_cert/myCA.pem

sslcrtd_program /usr/lib64/squid/security_file_certgen -s /var/lib/squid/ssl_db -M 20MB
ssl_bump stare all
ssl_bump bump all

cache_dir ufs /var/spool/squid 100 16 256

coredump_dir /var/spool/squid

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

shutdown_lifetime 1 second

我没有运行 iptables,所以我没有任何 REDIRECT 规则。我确实怀疑这是问题所在。

squid ssl-bumping
  • 2 个回答
  • 2016 Views
Martin Hope
Damiano Dotto
Asked: 2021-06-24 07:26:08 +0800 CST

Squid 代理服务配置问题

  • 0

我已经安装了 squid 代理来过滤来自 docker 的出站流量。具体来说,我使用 docker 创建了一个 jupyterhub 环境,以隔离每个用户并为他们提供虚拟环境。

现在我想过滤出站流量,以便他们只能访问某些域和使用 jupyterhub 的 docker 在本地安装的服务。

使用 cURL 调用代理可以正常工作。它只允许输入的域并使我们访问本地的 jupyterhub 服务。但是,要从Web界面打开它,会发生此错误:

在此处输入图像描述

我已经启用了 ip 172.17.0.1 和端口 8081 的服务,并且 cUrl 测试正在运行。

我该如何解决?

一些配置:

config.json (~/.config.json):

{
 "proxies":
{
   "default":
   {
     "httpProxy": "http://127.0.0.1:3128",
     "httpsProxy": "http://127.0.0.1:3128",
     "noProxy": "127.0.0.0/8"
   }
 }
}

squid.conf (/etc/squid/squid.conf):

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 localnet src 172.17.0.1/32

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 443         # https
acl CONNECT method CONNECT

#### 23/06/2021 #############
acl jupyterhub_port port 8081
acl jupyterhub_addr dst 172.17.0.1
http_access allow jupyterhub_port jupyterhub_addr

# 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

###### 18/06/2021

acl whitelist dstdomain .python.org .pypi.org .pythonhosted.org .pypa.io .yahoo.com
http_access allow whitelist

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

# Squid normally listens to port 3128
http_port 3128

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# 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

通过代理卷曲:

curl http://172.17.0.1:8081/hub/api --proxy 127.0.0.1:3128
{"version": "1.4.1"}
proxy squid docker
  • 1 个回答
  • 137 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve