Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Connecting to a database using a socks proxy?

by Skeeve (Parson)
on Sep 25, 2014 at 09:31 UTC ( #1101933=perlquestion: print w/replies, xml ) Need Help??

Skeeve has asked for the wisdom of the Perl Monks concerning the following question:

In my environment I use a socks proxy to connect to my database. This works fine for programs like the Java based DBVisualizer. I simply define the proxy in the connection's properties.

But how could I achieve this with perl? I have no clue which additional modules could help here. Or is there, maybe, no module required and a socks-connection is already possible?

Many thanks in advance for any useful hint.


Replies are listed 'Best First'.
Re: Connecting to a database using a socks proxy?
by Skeeve (Parson) on Feb 26, 2020 at 19:13 UTC

    More than 5 years passed and here I am, having that same question again…

    I cannot remember what I did 5 years ago as a workaround, but it's sad to see, no one seemed to have an answer :(


      Which database is it? I'm not sure about DBI (I don't think it supports the environment variable ALL_PROXY=socks5h://host:port?), but as a general solution, I've had some success with proxychains (and/or proxychains-ng depending on which your Linux distro provides). On newer Debian/Ubuntu releases, there's a package proxychains4 (alternatively, just proxychains), install that, and in /etc/proxychains.conf change the socks4 entry to socks5 if necessary and adjust the IP and port. Then, for many (but not all) programs, you can just do e.g. proxychains4 perl ... and it will try to intercept the networking to send it through the SOCKS proxy.

        Postgres is what I want to use.

        I saw that there is a DBD::Proxy but as far as I understood this is only for DBI::ProxyServer.

        I also wonder whether or not IO::Socket::Socks::Wrapper could be a way to go…

        Will think about proxychain but I'm not sure it's worth the effort. As it's mainly for testing purposes, I think I will (again?) go for port-forwarding.


      Just think, had you posted your solution.workaround in reply to your own question you wouldn't be in this situation ;)

        I come back for my own stub/test code a couple times a year. :P

        You ar right. And usually I do.

        So since I didn't, I think my workaround was not worth mentioning like: Using port forwarding instead of a socks proxy.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1101933]
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2020-07-03 16:57 GMT
Find Nodes?
    Voting Booth?

    No recent polls found