通过指定 jvm 参数
nohup java -Dhttps.proxySet=true -Dhttp.keepAlive=false -Dhttps.proxyHost=1.1.1.1 -Dhttps.proxyPort=3128 -jar x.jar &
通过nginx
内网机器ip : 1.1.1.1
跳板机(安装nginx) ip : 2.2.2.2
要调用的外网服务器ip : 9.9.9.9
在跳板机nginx做如下配置
server {
listen 9988;
location / {
# 注意不要以/结束,参加 //www.greatytc.com/p/b010c9302cd0
proxy_pass http://9.9.9.9:9999;
}
}
在内网机器1.1.1.1上 访问 http://2.2.2.2:9988 , 就能直接访问到 http://9.9.9.9:9999