Jenkins can listen on a Unix domain socket instead of a TCP port, which some reverse proxies use to connect to it, such as Apache and HAProxy.
Squid can’t connect to Jenkins in this way.
Squid forwards requests to a cache_peer, which is always addressed by a host name and an HTTP port (cache_peer hostname type http-port icp-port [options]), and Squid has no option to reach a peer through a Unix domain socket.
When Jenkins is behind Squid, keep Jenkins listening on a TCP port, as in the example above.
If Squid and Jenkins run on the same host, you can still keep Jenkins off the network by listening on the loopback address only.
With the Linux packages, set JENKINS_LISTEN_ADDRESS with systemctl edit jenkins:
[Service]
Environment="JENKINS_LISTEN_ADDRESS=127.0.0.1"
This passes --httpListenAddress=127.0.0.1 to Jenkins.
Then point Squid at the same address instead of localhost, which may resolve to the IPv6 address ::1:
cache_peer 127.0.0.1 parent 8080 0 originserver name=myAccel
systemctl edit only saves the setting, which takes effect the next time Jenkins is restarted (see Managing systemd services).
So apply the Squid change first, while Jenkins still listens on all addresses, and then restart Jenkins so that it listens on 127.0.0.1 only:
sudo squid -k reconfigure
sudo systemctl restart jenkins
Restarting Jenkins interrupts running builds.
To let them finish first, use Manage Jenkins > Prepare for Shutdown before restarting.