0

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?

Tarmo
  • 101
  • 2

1 Answers1

0

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.

Tarmo
  • 101
  • 2