[英]Java: -Dhttps.proxyHost not being used
I have a java application running on Tomcat in EC2 and I would like to reach a different EC2 endpoint via a proxy. 我有一个Java应用程序在EC2的Tomcat上运行,我想通过代理到达另一个EC2端点。 Let's call the source https://source.com
and destination https://destination.com
and the proxy https://proxy.com
我们将源https://source.com
和目标https://destination.com
以及代理https://proxy.com
称为
The symptom I have is the following: 我的症状如下:
wget destination.com
returns an output including connecting to the proxy and then connecting to destination.com
with a 200 ok. wget destination.com
返回的输出包括连接到代理,然后以200 ok连接到destination.com
。 org.springframework.web.client.ResourceAccessException: I/O error on GET request for "http://destination.com": Connect to destination.com:80 ... connect timed out; nested exception is org.apache.http.conn.ConnectTimeoutException
Things I've done: 我所做的事情:
http_proxy=http://destination.com:80 https_proxy=http://destination.com:80
Verify that java_opts include the proxy info as well: 验证java_opts也包括代理信息:
running ps -ef | grep app_name
运行ps -ef | grep app_name
ps -ef | grep app_name
returns the following: ps -ef | grep app_name
返回以下内容:
-Dhttp.proxyHost=destination.com -Dhttp.proxyPort=80 -Dhttps.proxyHost=destination.com -Dhttps.proxyPort=80
Even with these information exported and in the java_opts (set in setenv.sh
), it seems like the API is not using the proxy to reach the destination, because from the server, I can use wget/curl to reach the endpoint via the proxy. 即使出口这些信息,并在JAVA_OPTS(在设置setenv.sh
),这似乎是API不使用代理到达目的地,因为从服务器,我可以使用wget /卷曲通过代理到达终点。 Could there be another reason/location that I missed which is causing the API to not use the proxy? 我可能错过了另一个原因/位置,导致API不使用代理吗?
My java version here: java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
我在这里的Java版本: java -version java version "1.8.0_91" Java(TM) SE Runtime Environment (build 1.8.0_91-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)
Thanks in advance. 提前致谢。
You aren't using the Java API. 您没有使用Java API。 http[s].proxyHost
is for HttpURLConnection
and friends. http[s].proxyHost
用于HttpURLConnection
和朋友。 You appear to be using the Apache HTTP client, which evidently doesn't support them. 您似乎正在使用Apache HTTP客户端,该客户端显然不支持它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.