I recently found myself in a situation where I needed to access the public Internet from a instance that was not directly connected to the public Internet. The solution was to setup a SSH reverse tunnel to a local Squid proxy server and configure the instance to use the local proxy.
This is a guide to setting up a SSH reverse tunnel to a local Squid proxy server.
Prerequisites
- A local Squid proxy server, can be installed on macOS using Homebrew (
brew install squid
) - A SSH client
- The instance where Internet access is needed
Setup
- Start the Squid proxy server on the local machine
squid
- Setup the SSH reverse tunnel from the local machine to the instance
ssh -R 3128:localhost:3128 user@host
- Configure the instance to use the local proxy
export http_proxy=http://localhost:3128
export https_proxy=http://localhost:3128
- Verify the connection
curl addr.se
Notes
Both APT and Wget will respect the http(s)_proxy environment variables.