简体   繁体   中英

Direct connection to Internet without Proxy

Is it possible to make a Direct connection to the Internet without using a Proxy.

Consider a case that my Organization has a Proxy and I use the DIRECT option given in the Java Proxy class.

SocketAddress addr = new
InetSocketAddress("webcache.mydomain.com", 8080);
Proxy proxy = new Proxy(Proxy.Type.DIRECT, addr);

If you go by the documentation it states DIRECT which represents a direct connection, or absence of proxy.

Which is exactly the way it behaves. When I use this option, I dont have to give any Proxy details and I can access the content from the Internet.

I have three questions

  1. As per my understanding if an Organization has a Proxy, all network traffic should get routed through the Proxy. No one should be able to access the Network directly ?
  2. I also noted that if I remove the Proxy details from IE, I can not access the Web :-( How can Java still do it ?
  3. If in any Organization you can access both with the Proxy and Directly, how does the firewall block certain sites ? How does the firewall even work ?

Thanks in advance.

Proxy proxy = new Proxy(Proxy.Type.DIRECT, addr);

Is not the proper way to create a direct (no proxy) proxy directive. You should do

Proxy proxy = Proxy.NO_PROXY

The internal implementation of the Socket class and the HttpURLConnection checks if proxy == Proxy.NO_PROXY (note: "==", not "equals()"!).

It does NOT check if proxy.getType() == Proxy.Type.DIRECT .

2) You might have set the proxy in any system properties. If you are using any IDE, check the proxy setting of the IDE.

Not all Network traffic goes through a Proxy, if your Organization has a Proxy. You can still go ahead and establish a Direct connection to the Internet. Mostly the Organizations will block Direct connections and force you to use Proxies. Some times they might allow you to have a Restricted Direct connection, which allows certain URL's and denies other ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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