Tonλ's blog May the λ be with you

Polipo setup

by @ardumont on

I have got some speed troubles with my network from some time now. So here is one solution my team and I think of to overcome it.

We first created a vagrant machine with polipo inside. Now we moved on to a central machine to avoid the centralization of one person.

Install

sudo aptitude install polipo

Make it a service

sudo aptitude install chkconfig
sudo chkconfig polipo on

Setup

First, we will install the server part, then the client.

Server

When installing via ubuntu, the default setup is admittedly good. After all, so they say if we're confident with the first lines of the /etc/polipo/config.

# Sample configuration file for Polipo. -*-sh-*-

# You should not need to edit this configuration file; all configuration
# variables have reasonable defaults.

I'm confident with those default but I need to make some modifications regarding who is gonna use our proxy.

Open the proxy

We permit remote connections to the proxy.

proxyAddress=0.0.0.0
#allowedClients = 127.0.0.1, 192.168.0.0/24, 192.168.33.0/24

Note No access restriction regarding IP is done yet because I shamefully admit that I did not succeed yet.

(It's the second line where you can detail the ip or the range of ips you authorize to use the proxy)

Adding authentication

I want machine to authenticate in the proxy to use it. For this, add the authCredentials variable.

authCredentials=some-user:some-pass

Restart

At the end of the setup, restart the service.

sudo service polipo restart

Client

Setup

Personally, I use the /etc/environment file.

My personal setup:

  • proxy is on the 192.168.33.2 machine
  • proxy listens on port 8123.
  • credentials: some-user:some-pass.

Resulting to this, you can add the equivalent lines to your /etc/environment:

export http_proxy="http://some-user:some-pass@192.168.33.2:8123"
export https_proxy="http://some-user:some-pass@192.168.33.2:8123"
export ftp_proxy="http://some-user:some-pass@192.168.33.2:8123"
export no_proxy="localhost,192.168.33.2,localaddress,.localdomain.com"
export HTTP_PROXY="http://some-user:some-pass@192.168.33.2:8123"
export HTTPS_PROXY="http://some-user:some-pass@192.168.33.2:8123"
export FTP_PROXY="http://some-user:some-pass@192.168.33.2:8123"

Then reload your environment. You may need to logout and login again.

Note

As I use stumpwm, I personally only need to reload my stumpwm setup file (C-t ; then loadrc, or just as my settings goes, C-t L).

Check

Load a terminal and execute the command env | grep -i proxy, you should see something along those lines:

http_proxy=http://some-user:some-pass@192.168.33.2:8123
ftp_proxy=http://some-user:some-pass@192.168.33.2:8123
FTP_PROXY=http://some-user:some-pass@192.168.33.2:8123
HTTPS_PROXY=http://some-user:some-pass@192.168.33.2:8123
https_proxy=http://some-user:some-pass@192.168.33.2:8123
no_proxy=localhost,192.168.33.2,localaddress,.localdomain.com
HTTP_PROXY=http://some-user:some-pass@192.168.33.2:8123

Then requesting to wget google, you should see something along those lines too:

tony@dagobah(0,09,) 17:01:11 ~/repo/perso/vms/vagrant-http-proxy $ wget http://google.fr
--2012-12-26 17:01:21--  http://google.fr/
Connecting to 192.168.33.2:8123... connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: http://www.google.fr/ [following]
--2012-12-26 17:01:21--  http://www.google.fr/
Reusing existing connection to 192.168.33.2:8123.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'

    [ <=>                                                                                                                           ] 13 918      --.-K/s   in 0,04s

2012-12-26 17:01:21 (323 KB/s) - `index.html' saved [13918]

We see that we connect to the proxy 192.168.33.2 before requesting google. Victory!

Latest posts