You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/advanced-usage.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,6 +217,20 @@ When running Jedis in certain network environments, such as behind a NAT gateway
217
217
218
218
This allows you to dynamically map the address reported by a Redis node to a different address that the client can actually reach. You can implement this either by creating a dedicated class or by using a concise lambda expression.
219
219
220
+
### Example use case: NAT or Docker with different advertised ports
221
+
Suppose you run a Redis cluster inside Docker on a remote host.
222
+
Inside the cluster config, nodes announce addresses like:
223
+
```
224
+
172.18.0.2:6379
225
+
172.18.0.3:6379
226
+
172.18.0.4:6379
227
+
```
228
+
But externally, you reach them through the host IP with mapped ports:
229
+
```
230
+
my-redis.example.com:7001
231
+
my-redis.example.com:7002
232
+
my-redis.example.com:7003
233
+
```
220
234
### Implementing with a Dedicated Class
221
235
222
236
You can provide your mapping logic by creating a class that implements the `HostAndPortMapper` interface. This approach is useful for more complex mapping logic or for reusability.
@@ -245,11 +259,13 @@ Then, instantiate this class and pass it to the JedisCluster constructor:
0 commit comments