Question

I have two machines: machine foo (10.0.0.1) is running a redis server, and machine bar (192.168.0.1) is running a java application connecting to foo via jedis. Everything works fine when giving jedis the address 10.0.0.1.

But I don't trust the routers between foo and bar, and redis doesn't support ssl. So I set up an ssh tunnel from bar to foo: user@bar$ ssh -N -f -L localhost:6379:localhost:6379 user@foo

Now, from bar, I can successfully telnet to redis on foo either directly at 10.0.0.1 or over the tunnel at 127.0.0.1. With jedis, if I use 127.0.0.1 I get the exception java.net.ConnectException: Connection refused, but jedis can successfully connect to 10.0.0.1 just fine.

How can I convince jedis to use the ssh tunnel?

Était-ce utile?

La solution

The java app that is using jedis is a clustered application, and I had confused myself about which part of the application was launching jedis. Once I started the ssh tunnel on the master host rather than a slave, it all worked as expected.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top