【问题标题】:Spring - Direct all outbound traffic via a proxySpring - 通过代理引导所有出站流量
【发布时间】:2014-07-17 21:36:05
【问题描述】:

我有一个 Spring 应用程序,它使用 spring-ws 来处理我的所有 SOAP 消息,在我的本地开发机器上运行良好。当我部署到需要对任何流量使用代理才能到达外部世界的服务器时,我似乎被卡住了。我的印象是我可以设置一些 JVM 参数,例如

-Dhttp.proxyHost=proxyhostURL 
-Dhttp.proxyPort=proxyPortNumber 
-Dhttp.proxyUser=someUserName 
-Dhttp.proxyPassword=somePassword

但类文件似乎不支持 proxyUser 和 proxyPassword 参数。

我什至更进一步,在 java 代码中实现了它:

System.getProperties().put("http.proxyHost", "someProxyURL");
System.getProperties().put("http.proxyPort", "someProxyPort");
System.getProperties().put("http.proxyUser", "someUserName");
System.getProperties().put("http.proxyPassword", "somePassword");

但还是没有运气。

然后我尝试使用 java.net.Authenticator 设置用户名和密码,但这似乎也不起作用:

Authenticator.setDefault(
                  new Authenticator() {
                    public PasswordAuthentication getPasswordAuthentication() {
                      return new PasswordAuthentication(authUser, authPassword.toCharArray());
                    }
                  }
                );

有人对如何使用 Java6、Tomcat 6 和 Spring 3(使用 spring-ws)通过代理路由所有流量有任何建议

【问题讨论】:

    标签: java spring web-services spring-mvc proxy


    【解决方案1】:

    事实证明它不支持传入的 JVM HTTP 参数,因为我的 Web 服务使用的是 HTTPS。将标志设置为以下内容后:

    -Dhttps.proxyHost=proxyhostURL 
    -Dhttps.proxyPort=proxyPortNumber 
    -Dhttps.proxyUser=someUserName 
    -Dhttps.proxyPassword=somePassword
    

    一切都按计划进行。

    【讨论】:

    • 我怀疑这只能通过普通的代理服务器工作,而不是经过身份验证的代理服务器。 'https.proxyUser' 和 'https.proxyPassword' 不是 JVM 参数 AFAIK...
    猜你喜欢
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    • 2012-03-08
    • 1970-01-01
    • 1970-01-01
    • 2015-10-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多