Skip to content

Commit ab8c264

Browse files
committed
add spacing around code blocks to fix README rendering
1 parent d5b9ba7 commit ab8c264

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: README.md

+13
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
Let's suppose you were running multiple http application servers, but you only wanted to expose one machine to the internet. You could setup node-http-proxy on that one machine and then reverse-proxy the incoming http requests to locally running services which were not exposed to the outside network.
2424

2525
### Installing npm (node package manager)
26+
2627
```
2728
curl http://npmjs.org/install.sh | sh
2829
```
2930

3031
### Installing node-http-proxy
32+
3133
```
3234
npm install http-proxy
3335
```
@@ -51,6 +53,7 @@ In each of these scenarios node-http-proxy can handle any of these types of requ
5153
See the [examples][3] for more working sample code.
5254

5355
### Setup a basic stand-alone proxy server
56+
5457
``` js
5558
var http = require('http'),
5659
httpProxy = require('http-proxy');
@@ -70,6 +73,7 @@ http.createServer(function (req, res) {
7073
```
7174

7275
### Setup a stand-alone proxy server with custom server logic
76+
7377
``` js
7478
var http = require('http'),
7579
httpProxy = require('http-proxy');
@@ -95,6 +99,7 @@ http.createServer(function (req, res) {
9599
```
96100

97101
### Setup a stand-alone proxy server with latency (e.g. IO, etc)
102+
98103
``` js
99104
var http = require('http'),
100105
httpProxy = require('http-proxy');
@@ -130,6 +135,7 @@ http.createServer(function (req, res) {
130135
```
131136

132137
### Proxy requests within another http server
138+
133139
``` js
134140
var http = require('http'),
135141
httpProxy = require('http-proxy');
@@ -161,6 +167,7 @@ http.createServer(function (req, res) {
161167

162168
### Proxy requests using a ProxyTable
163169
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:
170+
164171
``` js
165172
var options = {
166173
router: {
@@ -172,6 +179,7 @@ var options = {
172179
```
173180

174181
The above route table will take incoming requests to 'foo.com/baz' and forward them to '127.0.0.1:8001'. Likewise it will take incoming requests to 'foo.com/buz' 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:
182+
175183
``` js
176184
var proxyServer = httpProxy.createServer(options);
177185
proxyServer.listen(80);
@@ -194,6 +202,7 @@ Notice here that I have not included paths on the individual domains because thi
194202

195203
### Proxy requests with an additional forward proxy
196204
Sometimes in addition to a reverse proxy, you may want your front-facing server to forward traffic to another location. For example, if you wanted to load test your staging environment. This is possible when using node-http-proxy using similar JSON-based configuration to a proxy table:
205+
197206
``` js
198207
var proxyServerWithForwarding = httpProxy.createServer(9000, 'localhost', {
199208
forward: {
@@ -208,6 +217,7 @@ The forwarding option can be used in conjunction with the proxy table options by
208217

209218
### Using node-http-proxy from the command line
210219
When you install this package with npm, a node-http-proxy binary will become available to you. Using this binary is easy with some simple options:
220+
211221
``` js
212222
usage: node-http-proxy [options]
213223

@@ -223,6 +233,7 @@ options:
223233
224234
### Proxying over HTTPS
225235
You have all the full flexibility of node-http-proxy offers in HTTPS as well as HTTP. The two basic scenarios are: with a stand-alone proxy server or in conjunction with another HTTPS server.
236+
226237
``` js
227238
var fs = require('fs'),
228239
https = require('https'),
@@ -263,6 +274,7 @@ https.createServer(options.https, function (req, res) {
263274
264275
### Proxying WebSockets
265276
Websockets are handled automatically when using the `httpProxy.createServer()`, but if you want to use it in conjunction with a stand-alone HTTP + WebSocket (such as [socket.io][5]) server here's how:
277+
266278
``` js
267279
var http = require('http'),
268280
httpProxy = require('http-proxy');
@@ -299,6 +311,7 @@ server.on('upgrade', function(req, socket, head) {
299311
If you have a suggestion for a feature currently not supported, feel free to open a [support issue][6]. 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.
300312
301313
## Run Tests
314+
302315
```
303316
vows test/*-test.js --spec
304317
vows test/*-test.js --spec --https

0 commit comments

Comments
 (0)