|
1 | 1 | # node-http2-proxy
|
2 | 2 |
|
3 |
| -A simple high performance http/2 & http/1.1 to http/1.1 spec compliant proxy helper for Node. |
| 3 | +A simple high performance http/2 & http/1 to http/1 spec compliant proxy helper for Node. |
4 | 4 |
|
5 | 5 | ### Features
|
6 | 6 |
|
7 |
| -- Proxies HTTP 2, HTTP 1.1 and WebSocket |
| 7 | +- Proxies HTTP 2, HTTP 1 and WebSocket |
8 | 8 | - Simple and high performance
|
9 | 9 | - [Hop by hop header handling](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers).
|
10 | 10 | - [Connection header handling](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Connection)
|
@@ -33,7 +33,7 @@ const server = http2.createServer({ allowHTTP1: true })
|
33 | 33 | server.listen(8000)
|
34 | 34 | ```
|
35 | 35 |
|
36 |
| -#### Proxy HTTP/2, HTTP/1.1 and WebSocket |
| 36 | +#### Proxy HTTP/2, HTTP/1 and WebSocket |
37 | 37 |
|
38 | 38 | ```js
|
39 | 39 | server.on('request', (req, res) => {
|
@@ -162,10 +162,10 @@ server.on('stream', (stream, headers) => {
|
162 | 162 |
|
163 | 163 | ```javascript
|
164 | 164 | server.on('stream', (stream, headers) => {
|
165 |
| - proxy.web(stream, { headers }, { |
| 165 | + proxy.web(stream, headers, { |
166 | 166 | hostname: 'localhost'
|
167 | 167 | port: 9000,
|
168 |
| - onReq: (stream, headers) => { |
| 168 | + onReq: (stream, { headers }) => { |
169 | 169 | headers['x-forwarded-for'] = stream.socket.remoteAddress
|
170 | 170 | headers['x-forwarded-proto'] = stream.socket.encrypted ? 'https' : 'http'
|
171 | 171 | headers['x-forwarded-host'] = stream.headers['host']
|
|
0 commit comments