Friday, September 27, 2019

Connection refused in ssh tunnel to apache forward proxy setup



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:





ServerAdmin xxxxxxxxxxxxxxxxxxxx
ServerName yyyyyyyyyyyyyyyyyyyy

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


ProxyRequests On


# deny access to all IP addresses except localhost
Order deny,allow
Deny from all
Allow from 127.0.0.1

# The following is my preference. Your mileage may vary.
ProxyVia Block
## allow SSL proxy
AllowCONNECT 443





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



#> ssh -L8080:localhost:8080 


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 ?



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. 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


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...