Ssh – Connection refused in ssh tunnel to apache forward proxy setup

apache-2.2mod-proxysshtunnel

I am trying to setup a private forward proxy in a small server. I mean to use it during a conference to tunnel my internet access through an ssh tunnel to the proxy server.

So I created a virtual host inside apache-2.2 running the proxy, the proxy_http and the proxy_connect module.
I use this configuration:

<VirtualHost localhost:8080>
        ServerAdmin xxxxxxxxxxxxxxxxxxxx
        ServerName yyyyyyyyyyyyyyyyyyyy

        ErrorLog /var/log/apache2/proxy-error_log
        CustomLog /var/log/apache2/proxy-access_log combined

        <IfModule mod_proxy.c>
                ProxyRequests On
                <Proxy *>
                        # deny access to all IP addresses except localhost
                        Order deny,allow
                        Deny from all
                        Allow from 127.0.0.1
                </Proxy>
                 # The following is my preference. Your mileage may vary.
                 ProxyVia Block
                ## allow SSL proxy
                AllowCONNECT 443
        </IfModule>
</VirtualHost>

After restarting apache I create a tunnel from client to server:

#> ssh -L8080:localhost:8080 <server address>

and try to access the internet through that tunnel:

#> links -http-proxy localhost:8080 http://www.linux.org

I would expect to see the requested page. Instead a get a "connection refused" error. In the shell holding open the ssh tunnel I get this:

channel 3: open failed: connect failed: Connection refused

Anyone got an idea why this connection is refused ?

Best Answer

I agree with CanOfSpam3 that using -D8080 is a better option then setting up a proxy with Apache. However, to answer your question, I would guess you have missed the Listen line in Apache to listen to port 8080 in addition to the usual ones. <VirtualHost> alone does not make Apache listen to the IP:Port mentioned, you also need to ask Apache to listen on that with Listen. Here's the reference from Apache