最近切换到不同的服务器,一些 php 文件使用 curl 并且最初似乎运行良好但不再那么多了。这是 google.com 的 curl_getinfo
array(20) {
["url"]=> string(22) "http://www.google.com/"
["content_type"]=> string(24) "text/html; charset=UTF-8"
["http_code"]=> int(200)
["header_size"]=> int(504)
["request_size"]=> int(1136)
["filetime"]=> int(-1)
["ssl_verify_result"]=> int(0)
["redirect_count"]=> int(1)
["total_time"]=> float(20.098232)
["namelookup_time"]=> float(0.006034)
["connect_time"]=> float(0.020963)
["pretransfer_time"]=> float(0.020999)
["size_upload"]=> float(0)
["size_download"]=> float(5481)
["speed_download"]=> float(272)
["speed_upload"]=> float(0)
["download_content_length"]=> float(5481)
["upload_content_length"]=> float(0)
["starttransfer_time"]=> float(0.047948)
["redirect_time"]=> float(20.035229)
}
Run Code Online (Sandbox Code Playgroud)
有 1 次重定向,不知何故需要 20 秒,基本上是我等待的时间的 100%。
还有其他一些奇怪的延迟,登录 ssh 需要 20-30 秒才能在密码后进行身份验证/拒绝,而这曾经是即时的。
有任何想法吗?
我最近将我的网站 SSL 证书换成了新的 Thawte 2048 位证书。
Ubuntu/libcurl 似乎无法验证它。Web 浏览器和 OSX 很好。
我必须从这里手动更新操作系统上的证书包:
任何想法为什么 Ubuntu 没有这些?
谢谢
标记
我遇到了一个问题,即某些首先尝试通过 HTTP/1.1 连接的客户端没有正确转发到 HTTPS
curl -v http://indentationerror.com/
* Trying 217.45.175.173:80...
* Connected to indentationerror.com (217.45.175.173) port 80 (#0)
> GET / HTTP/1.1
> Host: indentationerror.com
> User-Agent: curl/7.73.0
> Accept: */*
>
* Received HTTP/0.9 when not allowed
* Closing connection 0
curl: (1) Received HTTP/0.9 when not allowed
Run Code Online (Sandbox Code Playgroud)
但是,使用以下命令:
curl -v http://indentationerror.com/ --http2-prior-knowledge
Run Code Online (Sandbox Code Playgroud)
nginx 按预期通过 HTTP/2 返回 301 重定向
我的配置目前是:
server {
server_name www.indentationerror.com;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl on;
root "/http/indentationerror.com/www";
include /etc/nginx/genericHandlers/indentationerror.com;
} …Run Code Online (Sandbox Code Playgroud) 我使用的是亚马逊网络服务的服务器,并正在试图建立一个systemd作业需要作为输入AWS外部IP检索的curl。
[Unit]
Description=My example with AWS external IP
Wants=network-online.target
After=network-online.target
[Service]
Type=forking
Environment=EXTERNAL_IP=$(/usr/bin/curl http://169.254.169.254/latest/meta-data/public-ipv4)
ExecStart=/path/to/myexample $EXTERNAL_IP
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
验证工具systemd-analyze verify myexample.service表明curl环境分配存在问题。
Invalid environment assignment, ignoring: EXTERNAL_IP=$(/usr/bin/curl http://169.254.169.254/latest/meta-data/public-ipv4)
如果我用curl硬编码的 IP 字符串替换结果,我的守护进程就会启动。如何curl在我的 systemd 作业中使用结果?
我必须使用使用自签名证书(来自 Ubuntu)的服务。我已将公司的 CA 添加到受信任列表 (Ubuntu)。之后“链中自签名证书”错误消失了,但现在我收到“CA证书太弱”错误。例如
curl -vvv https://someservicehost.net
* Trying 93.184.216.34:443...
* TCP_NODELAY set
* Connected to someservicehost.net (93.184.216.34) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (OUT), TLS alert, bad certificate (554):
* SSL certificate problem: CA certificate key too …Run Code Online (Sandbox Code Playgroud) 我的系统是带有 WSL2 的 Win10,我运行了一个 dockergogs容器(来自 WSL 中的 ubuntu):
83b2a8833235 gogs/gogs "/app/gogs/docker/st…" 17 minutes ago Up 17 minutes 0.0.0.0:10022->22/tcp, :::10022->22/tcp, 0.0.0.0:10080->3000/tcp, :::10080->3000/tcp gogs
Run Code Online (Sandbox Code Playgroud)
我发现我可以卷曲它,但不能使用浏览器访问它:
>curl -vvv http://localhost:10080
* Rebuilt URL to: http://localhost:10080/
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 10080 (#0)
> GET / HTTP/1.1
> Host: localhost:10080
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 302 Found
< Content-Type: text/html; charset=utf-8
< Location: /install
< Set-Cookie: lang=en-US; Path=/; Max-Age=2147483647
< Set-Cookie: i_like_gogs=64602dcbf733a9e0; …Run Code Online (Sandbox Code Playgroud) 我需要在代理后面运行以下命令:
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
Run Code Online (Sandbox Code Playgroud)
返回与 SSL 相关的错误(因为代理将其证书放在中间)。我使用了“--insecure”并重新运行,这在一定程度上有效,但是 - 后来在该安装脚本中,再次调用curl,并返回相同的SSL错误。
我在 ~/.curlrc 中添加了“不安全”,以便调用脚本会忽略 SSL 错误..但是它们仍然会被抛出..如果我从一开始就删除 --insecure 它仍然有效(验证 .curlrc 工作)..所以我想这一定是权限问题..
运行“chmod 666 .curlrc”并使用“ls -l”验证所有的 rw - 相同的结果..如何忽略这些 SSL 错误?
我有 PHP 版本 5.5.21-1+deb.sury.org~precise+2在 Ubuntu 12.04 下使用 Apache2 运行
当我跑 phpinfo()它显示 curl 版本为7.22.0
当我跑 curl --version通过命令行- 它显示的版本为7.34.0
如何让 PHP 使用较新的版本?我需要一个卷曲版本>=7.24.0来满足我的需求
编辑:好的 - 我已经解决了一半的问题 - 这是我的curl --version输出:
curl 7.39.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
Run Code Online (Sandbox Code Playgroud)
所以我有 curl 7.39 - 但 libcurl/7.22
如何更新 libcurl?
这是Linux上的脚本:
if [ -s $WORK_DIR/newerfile ]
then
curl -k -T $WORK_DIR/newerfile -u username:password ftpssl.example.bank/inbound
fi
Run Code Online (Sandbox Code Playgroud)
我想将 curl 命令的结果放入我可以保存的文件中。我们正在向银行发送文件,并希望确保文件到达那里。我在 Linux 提示符下只使用了这个命令,它“似乎”可以工作(没有错误),但我没有看到任何输出。我阅读了 curl faqs 并且我知道进度表 - 它确实表明您可以将 shell > 用于文件,但由于我没有看到输出,我只是不知道。我真的对 curl 知之甚少。
curl ×9
ubuntu ×3
https ×2
php ×2
apache-2.2 ×1
centos ×1
http ×1
netstat ×1
networking ×1
nginx ×1
openssl ×1
ssl ×1
systemd ×1
ubuntu-12.04 ×1
ubuntu-20.04 ×1
windows-10 ×1