Score:0

Dockerised local Squid proxy gives 5xx errors to some requests done with Axios but works with others

cn flag

I'm trying to set up a local Squid proxy which does not cache anything. I am using Dockerised squid based on this image: https://hub.docker.com/r/ubuntu/squid

I run the image like so:

docker run -d --name squid-container -v /host/squid.conf:/etc/squid/squid.conf -e TZ=UTC -p 3128:3128 ubuntu/squid:4.13-21.10_edge

And I am now testing it via Node application with Axios like that:

  const res = await axios.get('https://www.google.com', {
    proxy: {
      host: 'localhost',
      port: 3128
    }
  });
  console.log(res.data);

It does not work. For the Google example it responds with HTTP 502 for example and in Squid logs I can see:

1646472971.202    183 172.17.0.1 TCP_MISS/502 3904 GET https://www.google.com/ - HIER_DIRECT/216.58.209.196 text/html

But for some requests it does work. For example https://ipfs.io/ipfs/QmTWMcWKgv2a5GjH6GoUjJXChZ55HAE3tVEXvPzpdbMnFU/102 works fine.

My Squid configuration (Some of the stuff put there is already gotten from researching this problem but none of them helped. Caching is intentionally turned off)

cache deny all
dns_v4_first on
forwarded_for off
via off
http_access allow all
acl all src all

The HTML page I get on error from Axios is:

The following error was encountered while trying to retrieve the URL: https://www.google.com/

Read Error

The system returned: [No Error]

An error condition occurred while reading data from the network. Please retry your request.

Your cache administrator is webmaster.

Without using the proxy, all the axios requests work. Does anyone know why some requests work and some don't?

Score:0
cn flag

This seems to be Axios issue not Squid configuration problem. With curl --proxy ... everything works like a charm. Found this ticket:

https://github.com/axios/axios/issues/658

Since I am not tied to Axios, I will use a different library. Hopefully this helps someone, as I spent way too much time on this.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.