--helpcurl的输出列出了一个--resolve选项,其中指出
--resolve <host:port:address> Force resolve of HOST:PORT to ADDRESS
Run Code Online (Sandbox Code Playgroud)
尽管如此,我没有任何运气让它工作。我试图运行的基本命令是
curl --resolve foo.example.com:443:localhost https://foo.example.com:443/
Run Code Online (Sandbox Code Playgroud)
我不断收到回应Couldn't resolve host 'foo.example.com'。我想这样做是因为我正在测试 foo.example.com 的证书,但我没有在实际服务器上测试它。相反,我在一个虚拟机器上测试它。我知道我可以编辑/etc/hosts以便 foo.example.com 解析为 localhost,但是如果我可以使它工作,这种 curl 方法似乎是“正确”的方法。
有人看到我在这里做错了吗?
Kei*_*son 72
似乎address需要是数字 IP 地址,而不是主机名。
尝试这个:
curl --resolve foo.example.com:443:127.0.0.1 https://foo.example.com:443/
Run Code Online (Sandbox Code Playgroud)
小智 6
一些额外的故障排除帮助:
确保您为协议列出了正确的端口:http=80; https=443 等
也curl -v将给予其可以帮助响应服务器的头信息。
$ curl -v --resolve foo.example.com:443:127.0.0.1 https://foo.example.com:443/
## The client request headers prepended by >
> OPTIONS /v1/..
> HOSTS foo.example.com
## The server response prepended by <
< HTTP/1.1 501 Not Implemented
## The html returned
<H1>Unsupported Request</H1>
Run Code Online (Sandbox Code Playgroud)
基本上在这种情况下,该OPTIONS HTTP方法并未在 CDN 的边缘服务器上实现。
| 归档时间: |
|
| 查看次数: |
78239 次 |
| 最近记录: |