Reputation: 3931
I have the -Dhttps.proxyHost=
set in the run command, is there some kind of logging I can enable to see when it is proxying a call? I need to verify that this is working.
I have also whitelisted a number of hosts via -Dhttp.nonProxyHosts=
so I want to make sure it is not proxying these.
Upvotes: 0
Views: 1883
Reputation: 98350
Create logging.properties
file with the following contents:
handlers = java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level = ALL
sun.net.www.protocol.http.HttpURLConnection.level = FINEST
Then add -Djava.util.logging.config.file=/path/to/logging.properties
JVM option.
Now you'll see log messages whenever HTTPS connection is established through a proxy:
May 30, 2020 2:12:56 AM sun.net.www.protocol.http.HttpURLConnection plainConnect0
FINEST: ProxySelector Request for https://example.com/
May 30, 2020 2:12:56 AM sun.net.www.protocol.https.HttpsClient New
FINEST: Looking for HttpClient for URL https://example.com and proxy value of HTTP @ 127.0.0.1:443
May 30, 2020 2:12:56 AM sun.net.www.protocol.https.HttpsClient <init>
FINEST: Creating new HttpsClient with url:https://example.com and proxy:HTTP @ 127.0.0.1:443 with connect timeout:-1
May 30, 2020 2:12:56 AM sun.net.www.protocol.http.HttpURLConnection plainConnect0
FINEST: Proxy used: HTTP @ 127.0.0.1:443
connect
system calls:$ sudo strace -f -p <PID> -e connect
After attaching to a Java process <PID>
with strace
, you'll see all addresses where the process connects to. If a proxy is used, there will be an address of the proxy.
[pid 12345] connect(263, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
Upvotes: 2