Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable/configure SOCKS proxy support in apache mod_proxy ( Apache2 )

I'm trying to find a documentation about how to setup apache2 mod_proxy with SOCKS proxy I've found this page http://menet.math.ecnu.edu.cn/manual/mod/mod_proxy.html#socks But it is about apache version 1, and I'm not sure that the recipe there still apply to version 2

What I'm trying to achieve is:

Have an apache2 serving my domain exampleA.com, and SOCKS proxy. They are both running on server A. SOCKS proxy is there so some apps on server A can communicate with other apps on servers B,C and it is running on localhost:4000

What I want is when user visit a specific url like http://exempleA.com/spetialurl/http://exampleB.com/xxx

this http request will be proxied via apache mod_proxy to server B - but through SOCKS proxy or if user access http://exempleA.com/spetialurl/http://exampleC.com/xxx this will be proxied to server C also through mod_proxy via SOCKS proxy

I can configure the mod_proxy to proxy a specyfic url to servers B or C What I'm missing is how to configure/tell apache2 to use the SOCKS proxy

This urls on servers B and C are not publicly visible, but they can be accessed through SOCKS proxy

like image 830
szydan Avatar asked Aug 31 '12 15:08

szydan


People also ask

How does Apache support proxy?

The Apache reverse proxy handles the incoming request, recognizes that an Apache ProxyPassReverse setting exists, and then forwards the request to Tomcat. Then Tomcat handles the request, returns a response to the Apache reverse proxy, and Apache returns the response to the client.

What is ProxyPass and ProxyPassReverse in Apache?

ProxyPassReverse will intercept those headers, and rewrite them to match the Apache proxy server. ProxyPass will create a reverse proxy. A reverse proxy (or gateway), appears to the client just like an ordinary web server. The client makes ordinary requests for content in the namespace of the reverse proxy.

What is mod_proxy in Apache?

mod_proxy is an optional module for the Apache HTTP Server. This module implements a proxy, gateway or cache for Apache. It implements proxying capability for AJP13 (Apache JServ Protocol version 1.3), FTP, CONNECT (for SSL), HTTP/0.9, HTTP/1.0, and (since Apache 1.3. 23) HTTP/1.1.


1 Answers

Unfortunately you can't use it directly. The closest thing that is there is below directive

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxyremote

And for me below config works great for an http proxy but not for an socks proxy

ProxyPass / http://ipinfo.io/
ProxyPassReverse / http://ipinfo.io/
ProxyRequests On
RequestHeader set Host "ipinfo.io"
ProxyRemote http http://185.93.3.123:8080

The result is below

IP Proxy Apache

Which shows that request is proxied correctly through the proxy. But doing it with a socks proxy results in 502 and I couldn't find a documentation saying socks5 is supported

So your option is to use something like polipo

https://www.irif.fr/~jch/software/polipo/

You can use it as a http->socks proxy forwarder and then ProxyRemote to the local polipo port

like image 182
Tarun Lalwani Avatar answered Oct 05 '22 06:10

Tarun Lalwani