Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@
- **web-outgoing:** Skip empty header names ([#121](https://github.com/unjs/httpxy/pull/121))
- **ssl:** Prevent undefined target values from overwriting ssl options ([#118](https://github.com/unjs/httpxy/pull/118))
- **utils:** Preserve target URL query string in path merging ([#117](https://github.com/unjs/httpxy/pull/117))
- **middleware:** Do not append duplicate x-forwarded-* header values ([#120](https://github.com/unjs/httpxy/pull/120))
- **middleware:** Do not append duplicate x-forwarded-\* header values ([#120](https://github.com/unjs/httpxy/pull/120))
- **web-outgoing:** Strip transfer-encoding on 204/304 ([#122](https://github.com/unjs/httpxy/pull/122))
- **web-incoming:** Use `isSSL` regex for consistent https/wss protocol checks ([#123](https://github.com/unjs/httpxy/pull/123))
- **ws:** Preserve wss:// protocol and fix error handling in proxyUpgrade ([cb01605](https://github.com/unjs/httpxy/commit/cb01605))

### 📦 Build

- ⚠️ Esm-only ([d65b3f7](https://github.com/unjs/httpxy/commit/d65b3f7))
- ⚠️ Esm-only ([d65b3f7](https://github.com/unjs/httpxy/commit/d65b3f7))

### 🏡 Chore

- Update deps ([743098d](https://github.com/unjs/httpxy/commit/743098d))

#### ⚠️ Breaking Changes

- ⚠️ Esm-only ([d65b3f7](https://github.com/unjs/httpxy/commit/d65b3f7))
- ⚠️ Esm-only ([d65b3f7](https://github.com/unjs/httpxy/commit/d65b3f7))

### ❤️ Contributors

Expand Down
58 changes: 31 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,33 @@ server.listen(3000, () => {

## Options

| Option | Type | Default | Description |
| ----------------------- | -------------------------------------- | -------- | --------------------------------------------------------------------------- |
| `target` | `string \| URL \| ProxyTargetDetailed` | — | Target server URL |
| `forward` | `string \| URL` | — | Forward server URL (pipes request without the target's response) |
| `agent` | `http.Agent` | — | Object passed to `http(s).request` for connection pooling |
| `ssl` | `https.ServerOptions` | — | Object passed to `https.createServer()` |
| `ws` | `boolean` | `false` | Enable WebSocket proxying |
| `xfwd` | `boolean` | `false` | Add `x-forwarded-*` headers |
| `secure` | `boolean` | — | Verify SSL certificates |
| `toProxy` | `boolean` | `false` | Pass absolute URL as path (proxy-to-proxy) |
| `prependPath` | `boolean` | `true` | Prepend the target's path to the proxy path |
| `ignorePath` | `boolean` | `false` | Ignore the incoming request path |
| `localAddress` | `string` | — | Local interface to bind for outgoing connections |
| `changeOrigin` | `boolean` | `false` | Change the `Host` header to match the target URL |
| `preserveHeaderKeyCase` | `boolean` | `false` | Keep original letter case of response header keys |
| `auth` | `string` | — | Basic authentication (`'user:password'`) for `Authorization` header |
| `hostRewrite` | `string` | — | Rewrite the `Location` hostname on redirects (301/302/307/308) |
| `autoRewrite` | `boolean` | `false` | Rewrite `Location` host/port on redirects based on the request |
| `protocolRewrite` | `string` | — | Rewrite `Location` protocol on redirects (`'http'` or `'https'`) |
| `cookieDomainRewrite` | `false \| string \| object` | `false` | Rewrite domain of `Set-Cookie` headers |
| `cookiePathRewrite` | `false \| string \| object` | `false` | Rewrite path of `Set-Cookie` headers |
| `headers` | `object` | — | Extra headers to add to target requests |
| `proxyTimeout` | `number` | `120000` | Timeout (ms) for the proxy request to the target |
| `timeout` | `number` | — | Timeout (ms) for the incoming request |
| `selfHandleResponse` | `boolean` | `false` | Disable automatic response piping (handle `proxyRes` yourself) |
| `followRedirects` | `boolean \| number` | `false` | Follow HTTP redirects from target. `true` = max 5 hops; number = custom max |
| `buffer` | `stream.Stream` | — | Stream to use as request body instead of the incoming request |
| Option | Type | Default | Description |
| ----------------------- | -------------------------------------- | ---------- | --------------------------------------------------------------------------- |
| `target` | `string \| URL \| ProxyTargetDetailed` | — | Target server URL |
| `forward` | `string \| URL` | — | Forward server URL (pipes request without the target's response) |
| `agent` | `http.Agent \| false` | keep-alive | Shared keep-alive agent by default. Set `false` to disable connection reuse |
| `ssl` | `https.ServerOptions` | — | Object passed to `https.createServer()` |
| `ws` | `boolean` | `false` | Enable WebSocket proxying |
| `xfwd` | `boolean` | `false` | Add `x-forwarded-*` headers |
| `secure` | `boolean` | — | Verify SSL certificates |
| `toProxy` | `boolean` | `false` | Pass absolute URL as path (proxy-to-proxy) |
| `prependPath` | `boolean` | `true` | Prepend the target's path to the proxy path |
| `ignorePath` | `boolean` | `false` | Ignore the incoming request path |
| `localAddress` | `string` | — | Local interface to bind for outgoing connections |
| `changeOrigin` | `boolean` | `false` | Change the `Host` header to match the target URL |
| `preserveHeaderKeyCase` | `boolean` | `false` | Keep original letter case of response header keys |
| `auth` | `string` | — | Basic authentication (`'user:password'`) for `Authorization` header |
| `hostRewrite` | `string` | — | Rewrite the `Location` hostname on redirects (301/302/307/308) |
| `autoRewrite` | `boolean` | `false` | Rewrite `Location` host/port on redirects based on the request |
| `protocolRewrite` | `string` | — | Rewrite `Location` protocol on redirects (`'http'` or `'https'`) |
| `cookieDomainRewrite` | `false \| string \| object` | `false` | Rewrite domain of `Set-Cookie` headers |
| `cookiePathRewrite` | `false \| string \| object` | `false` | Rewrite path of `Set-Cookie` headers |
| `headers` | `object` | — | Extra headers to add to target requests |
| `proxyTimeout` | `number` | `120000` | Timeout (ms) for the proxy request to the target |
| `timeout` | `number` | — | Timeout (ms) for the incoming request |
| `selfHandleResponse` | `boolean` | `false` | Disable automatic response piping (handle `proxyRes` yourself) |
| `followRedirects` | `boolean \| number` | `false` | Follow HTTP redirects from target. `true` = max 5 hops; number = custom max |
| `buffer` | `stream.Stream` | — | Stream to use as request body instead of the incoming request |

## Events

Expand Down Expand Up @@ -241,6 +241,10 @@ proxy.listen(3000);
- Install dependencies using `pnpm install`
- Run interactive tests using `pnpm dev`

## Acknowledgements

Performance optimizations in httpxy were inspired by analysis of [fast-proxy](https://github.com/fastify/fast-proxy) and [@fastify/http-proxy](https://github.com/fastify/fastify-http-proxy).

## License

Made with 💛
Expand Down
13 changes: 13 additions & 0 deletions bench/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:lts

COPY --from=alpine/bombardier /usr/bin/bombardier /usr/local/bin/bombardier
RUN corepack enable && corepack prepare pnpm@latest --activate

WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY bench/package.json bench/
RUN pnpm install --frozen-lockfile

COPY src/ src/
COPY bench/ bench/
COPY tsconfig.json ./
Loading
Loading