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
Copy file name to clipboardExpand all lines: README.md
+39-13
Original file line number
Diff line number
Diff line change
@@ -29,14 +29,25 @@ Let's suppose you were running multiple http application servers, but you only w
29
29
npm install http-proxy
30
30
</pre>
31
31
32
-
### How to setup a basic proxy server
32
+
## Using node-http-proxy
33
+
34
+
There are several ways to use node-http-proxy; the library is designed to be flexible so that it can be used by itself, or in conjunction with other node.js libraries / tools:
A Proxy Table is a simple lookup table that maps incoming requests to proxy target locations. Take a look at an example of the options you need to pass to httpProxy.createServer:
122
+
<pre>
123
+
var options = {
124
+
router: {
125
+
'foo.com': '127.0.0.1:8001',
126
+
'bar.com': '127.0.0.1:8002'
127
+
}
128
+
};
129
+
</pre>
130
+
131
+
The above route table will take incoming requests to 'foo.com' and forward them to '127.0.0.1:8001'. Likewise it will take incoming requests to 'bar.com' and forward them to '127.0.0.1:8002'. The routes themselves are later converted to regular expressions to enable more complex matching functionality. We can create a proxy server with these options by using the following code:
132
+
<pre>
133
+
var proxyServer = httpProxy.createServer(options);
134
+
proxyServer.listen(80);
135
+
</pre>
136
+
111
137
### Why doesn't node-http-proxy have more advanced features like x, y, or z?
112
138
113
139
If you have a suggestion for a feature currently not supported, feel free to open a [support issue](http://github.com/nodejitsu/node-http-proxy/issues). node-http-proxy is designed to just proxy http requests from one server to another, but we will be soon releasing many other complimentary projects that can be used in conjunction with node-http-proxy.
0 commit comments