URL funciona no wget mas não no curl (relacionado ao apt)

1

Este é um caso estranho que me faz coçar a cabeça. Para começar, achei esse erro originalmente quando executei um sudo apt-get update e recebi

Err https://packagecloud.io jessie/main amd64 Packages                         
  Failed to connect to packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com port 443: Network is unreachable
Err https://packagecloud.io jessie/main i386 Packages                          
  Failed to connect to packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com port 443: Network is unreachable
Hit http://ppa.launchpad.net trusty/main i386 Packages                         

[...snipped...]

W: Failed to fetch https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/main/binary-amd64/Packages  Failed to connect to packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com port 443: Network is unreachable

W: Failed to fetch https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/main/binary-i386/Packages  Failed to connect to packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com port 443: Network is unreachable

E: Some index files failed to download. They have been ignored, or old ones used instead.

Nota: Eu estou no Ubuntu 14.04 Trusty, mas eu configurei para fazer o download do Debian Jessie repo. Este não é o problema.

Seguir esta URL (ou seja, link ) no navegador mostra que é perfeitamente navegável. Daí eu queria verificar se algo está errado com o meu apt . Por isso, usei curl e wget e obtive resultados diferentes:

Para curl :

$ curl -v https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/main/binary-i386/Packages
* Hostname was NOT found in DNS cache
*   Trying 50.97.198.58...
*   Trying 2607:f0d0:2101:270::2...
* connect to 2607:f0d0:2101:270::2 port 443 failed: Network is unreachable
* Failed to connect to packagecloud.io port 443: Network is unreachable
* Closing connection 0
curl: (7) Failed to connect to packagecloud.io port 443: Network is unreachable

Para wget :

wget -d https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/main/binary-i386/Packages
DEBUG output created by Wget 1.15 on linux-gnu.

URI encoding = ‘UTF-8’
--2017-07-21 18:11:10--  https://packagecloud.io/slacktechnologies/slack/debian/dists/jessie/main/binary-i386/Packages
Resolving packagecloud.io (packagecloud.io)... 50.97.198.58, 2607:f0d0:2101:270::2
Caching packagecloud.io => 50.97.198.58 2607:f0d0:2101:270::2
Connecting to packagecloud.io (packagecloud.io)|50.97.198.58|:443... connected.
Created socket 3.
Releasing 0x00000000018412b0 (new refcount 1).
Initiating SSL handshake.
Handshake successful; connected socket 3 to SSL handle 0x00000000018415e0
certificate:
  subject: /OU=Domain Control Validated/OU=EssentialSSL/CN=packagecloud.io
  issuer:  /C=GB/ST=Greater Manchester/L=Salford/O=COMODO CA Limited/CN=COMODO RSA Domain Validation Secure Server CA
X509 certificate successfully verified and matches host packagecloud.io

---request begin---
GET /slacktechnologies/slack/debian/dists/jessie/main/binary-i386/Packages HTTP/1.1
User-Agent: Wget/1.15 (linux-gnu)
Accept: */*
Host: packagecloud.io
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 302 Found
Server: nginx
Date: Fri, 21 Jul 2017 12:41:17 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 0
Connection: keep-alive
Status: 302 Found
Strict-Transport-Security: max-age=31536000
Location: https://packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com/925/1150/debian/dists/jessie/main/binary-i386/Packages?AWSAccessKeyId=AKIAI44QGWC7C5WEV4XA&Signature=Vltn5Ghi49icZIN7Ho5DphMEbRE%3D&Expires=1500641185
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
X-Request-Id: 571637cb-6a78-47b1-8558-45a67c428064
X-Runtime: 0.018935

---response end---
302 Found
Registered socket 3 for persistent reuse.
URI content encoding = ‘utf-8’
Location: https://packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com/925/1150/debian/dists/jessie/main/binary-i386/Packages?AWSAccessKeyId=AKIAI44QGWC7C5WEV4XA&Signature=Vltn5Ghi49icZIN7Ho5DphMEbRE%3D&Expires=1500641185 [following]
] done.
URI content encoding = None
--2017-07-21 18:11:11--  https://packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com/925/1150/debian/dists/jessie/main/binary-i386/Packages?AWSAccessKeyId=AKIAI44QGWC7C5WEV4XA&Signature=Vltn5Ghi49icZIN7Ho5DphMEbRE%3D&Expires=1500641185
Resolving packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com (packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com)... 52.219.20.25, 2600:1fa0:c040:80:36e7:ec1c::
Caching packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com => 52.219.20.25 2600:1fa0:c040:80:36e7:ec1c::
Connecting to packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com (packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com)|52.219.20.25|:443... connected.
Created socket 4.
Releasing 0x000000000185a150 (new refcount 1).
Initiating SSL handshake.
Handshake successful; connected socket 4 to SSL handle 0x0000000001860bc0
certificate:
  subject: /C=US/ST=Washington/L=Seattle/O=Amazon.com Inc./CN=*.s3-us-west-1.amazonaws.com
  issuer:  /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert Baltimore CA-2 G2
X509 certificate successfully verified and matches host packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com

---request begin---
GET /925/1150/debian/dists/jessie/main/binary-i386/Packages?AWSAccessKeyId=AKIAI44QGWC7C5WEV4XA&Signature=Vltn5Ghi49icZIN7Ho5DphMEbRE%3D&Expires=1500641185 HTTP/1.1
User-Agent: Wget/1.15 (linux-gnu)
Accept: */*
Host: packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 200 OK
x-amz-id-2: cDzrsyunzEU7POUHrPqzqAV+oPLWkeRrMPgDQeKATtgenMpv2EUbCQjy+88AKQ6rp8FTO2shkv0=
x-amz-request-id: 76F0FF5E248DAFDE
Date: Fri, 21 Jul 2017 12:41:19 GMT
Last-Modified: Thu, 08 Jun 2017 00:13:11 GMT
ETag: "857ccd845e08a3963199ffbb587a0f4f"
Cache-Control: max-age=31536000
Accept-Ranges: bytes
Content-Type: text/plain
Content-Length: 20053
Server: AmazonS3

---response end---
200 OK
Disabling further reuse of socket 3.
Closed 3/SSL 0x00000000018415e0
Registered socket 4 for persistent reuse.
Length: 20053 (20K) [text/plain]
Saving to: ‘Packages’

100%[====================================================================================================================================================================>] 20,053      46.6KB/s   in 0.4s   

2017-07-21 18:11:12 (46.6 KB/s) - ‘Packages’ saved [20053/20053]

Basicamente, o URL parece funcionar através de wget e do navegador, mas não através de apt-get ou curl .

Eu não tenho nenhum proxy instalado, nem mexi com nenhuma configuração relacionada à rede recentemente. No entanto, esse problema surgiu no último mês +, e eu adoraria saber de possíveis coisas que eu poderia tentar depurar / corrigir isso.

    
por Jay Bosamiya 21.07.2017 / 14:46

1 resposta

3

Anote o código de status HTTP 302. Este é um redirecionamento, o que significa que o URL fornecido mapeia para outro URL. Wget por padrão segue redirecionamentos, curl não. Os navegadores também costumam seguir redirecionamentos por padrão. Para fazer o curl seguir os redirecionamentos, use a opção -L or --location .

Citando a página man,

  

-L, --localização   (HTTP) Se o servidor informar que a página solicitada foi movida para um   localização (indicado por um local: cabeçalho e um código de resposta 3XX), esta opção   fará com que a onda refaça o pedido no novo local.

Infelizmente, não posso ajudar com a parte do apt-get, já que não sou especialista em Ubuntu. Apenas pensei nisso, você poderia alterar a localização do site de atualização para

packagecloud-repositories.s3.dualstack.us-west-1.amazonaws.com/925/1150/debian/dists/jessie/main/binary-i386/Packages?AWSAccessKeyId=AKIAI44QGWC7C5WEV4XA&Signature=Vltn5Ghi49icZIN7Ho5DphMEbRE%3D&Expires=1500641185

em vez de

packagecloud.io/slacktechnologies/slack/debian/dists/jessie/main/binary-i386/Packages

?

Espero que isso ajude!

    
por vikarjramun 21.07.2017 / 16:10