简体   繁体   English

在Windows的squid代理后面运行的Java servlet应用程序

[英]Java servlet application running behind squid proxy on windows

I'm behind a squid HTTP proxy requiring authentication and want to make API requests to an external server. 我在需要身份验证的鱿鱼HTTP代理后面,想向外部服务器发出API请求。 However when I do so, I get the following error : 但是,当我这样做时,出现以下错误:

Caused by: java.io.IOException: Unable to tunnel through proxy. 原因:java.io.IOException:无法通过代理隧道传输。 Proxy returns "HTTP/1.0 407 Proxy Authentication Required" 代理返回“需要HTTP / 1.0 407代理身份验证”

I've tried setting the proxy configuration by going to Control Panel > Java > Network Settings, but to no avail. 我尝试通过转到控制面板> Java>网络设置来设置代理配置,但无济于事。 How to solve this? 如何解决呢?

You should set the proxy-settings in java. 您应该在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");

Copy from http://www.it.iitb.ac.in/~roshan/articles/javahttpproxy.html : http://www.it.iitb.ac.in/~roshan/articles/javahttpproxy.html复制:

Tomcat Settings: catalina.properties Tomcat设置:catalina.properties

Append these properties to the catalina.properties file in Tomcat: ${CATALINA_OME}/conf/catalina.properties file: 将这些属性附加到Tomcat中的catalina.properties文件:$ {CATALINA_OME} /conf/catalina.properties文件:

http.proxyHost=yourProxyURL http.proxyPort=yourProxyPort http.proxyUser=yourUserName http.proxyPassword=yourPassword Tomcat Settings: catalina.bat http.proxyHost = yourProxyURL http.proxyPort = yourProxyPort http.proxyUser = yourUserName http.proxyPassword = yourPassword Tomcat设置:catalina.bat

Add all the parameters defined above in the ${CATALINA_HOME}/bin/catalina.bat (for Windows) or ${CATALINA_HOME}/bin/catalina.bat (for *nix): JAVA_OPTS="-Dhttp.proxyHost=yourProxyURL ..." (Each option is seperated by spaces.) 添加或在上面的$ {CATALINA_HOME} /bin/catalina.bat(适用于Windows)中定义的所有参数$ {CATALINA_HOME} /bin/catalina.bat(用于* nix):JAVA_OPTS =“ - Dhttp.proxyHost = yourProxyURL .. ”。(每个选项都用空格分隔。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM