![无法在某些平台上使用 cURL,特别是 DigitalOcean VPS](https://linux22.com/image/1705348/%E6%97%A0%E6%B3%95%E5%9C%A8%E6%9F%90%E4%BA%9B%E5%B9%B3%E5%8F%B0%E4%B8%8A%E4%BD%BF%E7%94%A8%20cURL%EF%BC%8C%E7%89%B9%E5%88%AB%E6%98%AF%20DigitalOcean%20VPS.png)
我在 Ubuntu 23.10 (GNU/Linux 6.5.0-27-generic x86_64) 上无法工作,curl 是 8.2.1 怀疑是机器上有问题。
我有两个基于 Digital Ocean 服务的虚拟专用服务器 (VPS),在这两个服务器上我都无法执行以下 cURL 命令并收到有效响应(页面源),并出现相同的内部服务器错误响应:
curl -v -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" https://www.chanel.com/it/profumi/p/114460/egoiste-eau-de-toilette-vaporizzatore
需要注意的是,该-L
选项用于跟踪重定向,上面的行提供了一个有效的 200 响应,其中 curl 列出了所有网页源代码。以下是我收到的完整响应:
curl -V
curl 8.2.1 (x86_64-pc-linux-gnu) libcurl/8.2.1 OpenSSL/3.0.10 zlib/1.2.13 brotli/1.0.9 zstd/1.5.5 libidn2/2.3.4 libpsl/0.21.2 (+libidn2/2.3.3) libssh/0.10.5/openssl/zlib nghttp2/1.55.1 librtmp/2.3 OpenLDAP/2.6.6
Release-Date: 2023-07-26
Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
curl -v -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" https://www.chanel.com/it/profumi/p/114460/egoiste-eau-de-toilette-vaporizzatore
* Trying 23.36.163.227...
* TCP_NODELAY set
* Connected to www.chanel.com (23.36.163.227) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
* ALPN, server accepted to use h2
* Server certificate:
* subject: C=FR; ST=le-de-France; L=Neuilly-sur-Seine; O=CHANEL SAS; CN=*.chanel.com
* start date: Dec 17 00:00:00 2023 GMT
* expire date: Dec 17 23:59:59 2024 GMT
* subjectAltName: host "www.chanel.com" matched cert's "*.chanel.com"
* issuer: C=US; O=DigiCert Inc; CN=DigiCert TLS RSA SHA256 2020 CA1
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55d2c4ac4110)
> GET /it/profumi/p/114460/egoiste-eau-de-toilette-vaporizzatore HTTP/2
> Host: www.chanel.com
> User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
> Accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Connection state changed (MAX_CONCURRENT_STREAMS == 100)!
* HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)
* stopped the pause stream!
* Connection #0 to host www.chanel.com left intact
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)
我这样做只是为了测试机器连接性,因为我遇到了问题php-webdriver
并且docker-selenium
响应是 301 状态页面,所以我使用 cURL 进行了测试,看起来我发现有一些与 selenium 无关的根本原因。