You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want a simple standalone proxy balancer from command line check out[proxy-supervisor-cli](https://github.com/vladislao/proxy-supervisor-cli) or [dockerized proxy-supervisor](https://hub.docker.com/r/vladislaosan/proxy-supervisor).
22
+
For a straightforward standalone proxy balancer accessible via command line, explore[proxy-supervisor-cli](https://github.com/vladislao/proxy-supervisor-cli) or [dockerized proxy-supervisor](https://hub.docker.com/r/vladislaosan/proxy-supervisor).
23
23
24
24
## Usage
25
25
26
-
Just initialize a balancer and add some proxies.
26
+
Start by initializing a balancer and adding your proxies:
Great! Now let's get it to work. Create a middleware and put it in your route. To simplify example, we will use plain http server.
37
+
// Now, integrate it into your application. Below, we set up a basic HTTP server using the balancer as middleware.
39
38
40
-
```javascript
41
39
http
42
40
.createServer(awesomeBalancer.proxy())
43
41
.on("connect", awesomeBalancer.connect())
44
42
.listen(3000);
45
43
```
46
44
47
-
Awesome! Next step is to set your balancing server as a proxy server wherever you want to use proxies. This server will proxy requests using specified list of proxies. The final trace will look like that _(you) -> (balancer) -> (proxy) -> (endpoint)_.
48
-
49
-
Finding proxies and adding them by hand is painful. Even more, you will probably want to remove dead ones. To simplify that process you can use _sources_. Let's add a few sources.
45
+
Great! The next step is to configure your balancing server as the proxy server in any application that needs to use proxies. This setup will channel requests through the specified proxies, forming a path like _(you) -> (balancer) -> (proxy) -> (endpoint)_.
Done! Sources will automatically replenish your balancer with new proxies. You should be able to find more sources on [github](https://github.com/). So, what about unreachable proxies? Let's add a monitor to filter them out!
49
+
In scenarios where a proxy requires authorization, use the _formatHeaders_ function. This function enables you to embed proxy credentials in the URL (e.g., https://login:password@MY_PROXY:3123) and set the appropriate authorization header. Here's how to implement it:
Monitor will trigger for every 5 minutes and remove proxies, that didn't respond with successful status code. Best practice would be to specify your own server, and make sure port is open.
You are not limited in the way you can use balancers. For example, you can have different balancers on different routes. Sources designed to work with multiple balancers.
@@ -131,6 +98,8 @@ Subscribes to the specified source.
131
98
-**options**_\<Object\>_ Configuration details.
132
99
133
100
-**timeout**_\<Integer\>_ Sets the socket to timeout after timeout milliseconds of inactivity. Note that increasing the timeout beyond the OS-wide TCP connection timeout will not have any effect ([the default in Linux can be anywhere from 20-120 seconds](http://www.sekuda.com/overriding_the_default_linux_kernel_20_second_tcp_socket_connect_timeout)). Defaults to 30 seconds.
101
+
102
+
-**formatHeaders**_\<Function\>_ This function is designed to modify headers before a request is sent through your proxy. It is commonly used for handling proxy authorization. The function signature is _(proxy, headers)_, and it must return an updated headers object.
134
103
135
104
- Returns: _\<Function\>_
136
105
@@ -142,6 +111,8 @@ Creates a middleware function. Middleware has a signature of _(req, res, next)_.
142
111
143
112
-**timeout**_\<Integer\>_ Sets the socket to timeout after timeout milliseconds of inactivity. Defaults to 30 seconds.
144
113
114
+
-**formatHeaders**_\<Function\>_ This function is designed to modify headers before a request is sent through your proxy. It is commonly used for handling proxy authorization. The function signature is _(proxy, headers)_, and it must return an updated headers object.
115
+
145
116
- Returns: _\<Function\>_
146
117
147
118
Creates a handler for HTTP CONNECT method. [It is used to open a tunnel between client and proxy server](https://tools.ietf.org/html/rfc2817#section-5.2).
0 commit comments