Use Squid as HTTP / HTTPS / SSH Proxy

Guide to install Squid proxy server to proxy HTTP, HTTPS and SSH.

When is it useful

Sometimes you need to serve the internet as if you are on another location. Some examples:

  • Test CDN solutions
  • View localized Adwords / Facebook ads
  • Use services that are available only in some territories.
  • Use SSH on a LAN that does not have outbound port 22 open.

Solutions

Possible solutions to get a proxy:

  • Use premium proxy service (subscription fees from $ 12.00 - $ 50.00 p/m)
  • Create simple server with Proxy server installed.

We found the latter solution the most affordable and flexible. And it is easy as well.

Configure Squid proxy on Ubuntu for HTTP, HTTPS and SSH

  1. create an Ubuntu or Debian Virtual server.
  2. install the Squid proxy server: apt-get install squid
  3. configure squid (see chapter below: configure Squid)
  4. restart squid (service squid restart)

Configure Squid

Open the configuration file in an editor: vi /etc/squid/squid.conf

Allow your client IP’s to use proxy

Locate INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS and add the following lines below:

acl holiday_location src 82.236.191.91
http_access allow holiday_location

Allow SSH port (22) to be proxied

Locate acl SSL_ports port 443

Add above the following line:

acl SSL_ports port 22   # ssh

Locate acl Safe_ports port 21

Add the following line below:

acl Safe_ports port 22          # ssh

Restart Squid

Don’t forget to restart squid using command: service squid restart

Configure SSH clients to connect via proxy

Install Corkscrew

Next, in ~/.ssh/config, add the following block:

host * 
    ProxyCommand corkscrew proxy-hostname-or-ip-address 8080 %h %p

Now connect to SSH servers as usual to connect via a proxy.