更新时间:2021-10-14 23:16:34
假设你在 UNIX/Linux 平台上,想法是你做一个
Assuming that you are on a UNIX/Linux platform, the idea is that you do a
ssh -L 3306:mysql-server:3306 username@mysql-server
从你的 spring boot 应用程序中,你连接到 localhost:3306
,它被转发到端口 3306
上的 mysql-server
.
From within you spring boot application, you do a connect to localhost:3306
which is forwarded to the mysql-server
on port 3306
.
直接在 spring boot 中执行此操作,您应该使用 Java 安全通道.此处描述了端口转发的示例.
Doing it directly inside spring boot, you should go with Java Secure Channel. An example for port forwarding is described here.