简体   繁体   English

Java:未使用-Dhttps.proxyHost

[英]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: 我的症状如下:

  1. Hitting the endpoint from my source server works: 从我的源服务器命中端点可以正常工作:
    • 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
  2. When I try to make the call using postman via the API on the source, I get the below error: 当我尝试通过源上的API使用邮递员进行呼叫时,出现以下错误:

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: 我所做的事情:

  • Verify that the http and https proxy is exported 验证是否已导出http和https代理
    • I have both of these exported as an environment variable: 我将它们都导出为环境变量:
    • 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.

相关问题 jar 文件执行适用于 -Dhttps.proxyHost 选项,但当我通过导出设置相同的代理然后运行 java -jar sample.Z68995FCBF432492D15484D04A9D2AC04 时不起作用 - jar file execution works with -Dhttps.proxyHost option but does not work when I set the same proxy via export and then if I run java -jar sample.jar Java Web Start和proxyPort / proxyHost - Java Web Start & proxyPort/proxyHost 为什么tomcat servlet不使用JVM参数http.proxyHost? - Why is the JVM parameter http.proxyHost not used by tomcat servlets? Java系统属性重置http.proxyHost和ProxyPort - Java System Properties reset http.proxyHost and ProxyPort Java系统属性,http.proxyHost,两个问题 - Java system Properties, http.proxyHost, two questions Java https代理(使用https.proxyPort和https.proxyHost) - Java https proxy (using https.proxyPort and https.proxyHost) 变量没有被使用,但显然是! -Java - Variables not being used but clearly are! - Java Java-'\\'不用于转义字符串中的双引号 - Java - '\' not being used to escape double quotes " in string 自定义Java类加载器没有用于加载依赖项? - Custom Java classloader not being used to load dependencies? Java阵列未打印(正在使用BlueJ) - Java Array Not Printing (BlueJ being used)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM