i checked this page and got some usefull code for using a proxy in java code when connecting to a webpage.
I can confirm that pages like whatsmyip do indeed tell me that proxy is working - it is showing proxy ip. The problem is that the page i am accesing to in java code, somehow detects my true ip and blocks content. I do know how it does that (header, return ip, etc.), what i do not know is how to bypass that.
Maybe another interesting thing is that this page works with no problems using 1 of the best known online proxy sites - it shows content. Now what is even more interesting is that i tried taking that sites ip and used it as proxy in my program, but there it didn't work - true ip got detected, which is really strange.
edit: This is my new code:
System.setProperty("java.net.useSystemProxies","false");
System.setProperty("http.proxyHost", "94.230.208.147");
System.setProperty("http.proxyPort", "9001");
System.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
System.setProperty("https.proxyHost", "94.230.208.147");
System.setProperty("https.proxyPort", "9001");
System.setProperty("https.nonProxyHosts", "localhost|127.0.0.1");
I can confirm that https://whatsmyip.com/ isn't fooled by this proxy and can see my true ip. What did i forget to include ?
Add this at the end of your code:
System.setProperty("http.nonProxyHosts", "localhost|127.0.0.1");
That indicates the hosts that should be accessed without going through the proxy. Typically this defines internal hosts. The value of this property is a list of hosts, separated by the '|' character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With