我正在运行本地http服务器和本地squid实例。本地http客户端打开连接到squid实例的套接字,该套接字似乎可以工作。然后,通过发出以下http请求,尝试引导到本地http服务器:
CONNECT localhost:80 HTTP/1.1\r\n
,这将产生响应头。
Content-Language en
Content-Length 3612
Content-Type text/html;charset=utf-8
Date Thu, 21 Jun 2018 17:28:10 GMT
Mime-Version 1.0
Server squid/3.5.27
Vary Accept-Language
X-Squid-Error ERR_DNS_FAIL 0
现状503。我还尝试连接到127.0.0.1,这将产生以下响应:
Content-Language en
Content-Length 3433
Content-Type text/html;charset=utf-8
Date Thu, 21 Jun 2018 17:35:16 GMT
Mime-Version 1.0
Server squid/3.5.27
Vary Accept-Language
X-Squid-Error ERR_CONNECT_FAIL 111
我的squid.conf看起来是这样的:
http_port 3128
coredump_dir /var/spool/squid
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 1025-65535 # unregistered ports
acl CONNECT method CONNECT
acl any_host src all
acl all_dst dst all
http_access allow any_host
http_access allow all_dst
有没有不同的方式告诉鱿鱼连接到本地主机?
发布于 2018-06-22 12:30:29
不知何故,squid试图将localhost
解析为127.0.0.1
,最终导致连接失败。但是,指定[::1]
而不是localhost
将按预期执行。
发布于 2019-02-01 19:55:32
我发现失败的是localhost
解析成[::1]
而不是127.0.0.1
。
为了绕过/etc/hosts/
,只需在/etc/squid/hosts
中添加以下内容
127.0.0.1 localhost
然后hosts_file /etc/squid/hosts
在你的squid.conf
。
当然,这个文件可以放在任何你想要的地方。
发布于 2021-10-12 15:26:34
在我的例子中,我使用了squid机器主机名(例如,mysquid.proxy),并且这个问题与DNS解析无关,因为squid机器可以使用其主机名正确地解决自己的问题。
这个问题是由于在同一个代理中配置了额外的端口而造成的。我使用squid作为前向代理和反向代理,具有两个不同的端口:
客户端连接到(转发)代理mysquid.proxy:3128,请求类似于:
CONNECT mysquid.proxy:443 HTTP/1.1
最后使用了反向代理端口。但是,在该端口上,它配置了一个程序 ( Perl脚本)来过滤和更改特定url的某些路径,这样的脚本错误地将请求重定向到一个不存在的url,从而导致客户端中的错误"503服务不可用“。
https://stackoverflow.com/questions/50974570
复制相似问题