How does Java implement a proxy server?


Sandra Pique


The role of proxy server is obvious to all. It really brings us great convenience. How does Java implement proxy server?

First, this requirement can be simplified to:

1. The proxy service host intercepts the request between the client and the proxy service host, and then directly forwards the information to the target host;

2. The proxy service host forwards the response of the target host directly to the client.

The proxy service host can directly obtain the data message sent by the client to the designated port of the local machine through the socket, then the information that the client wants to send to the target host can be obtained by analyzing the content. The proxy service host can re request through the socket and forward the content in the original request to the target host, The response from the target host is then forwarded to the client.

For Java se projects, there are two ways to implement:

1. Using native java socket programming. (multithreading problem...)

2. Adopt the third-party network application framework, such as Mina, netty, etc. (simple development, stable and reliable)

For Java Web projects, there are also two ways to implement them:

1. Adopt the above Java se scheme.

2. HTTP proxy intercepts the client's request and sends get / post request to the target server using HTTP protocol.

If the IP needs to be an e-commerce platform or social media, consider selecting roxlabs dedicated computer room IP. Fast IP, easy to set, unlimited traffic.

More on: Roxlabs proxy 

Recent posts


Sandra Pique

How do I setup a SOCKS5 proxy?