
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
flexible-reverse-proxy
Advanced tools
A simple reverse proxy server with configurable routing and CORS support.
npm install -g flexible-reverse-proxy
npm install flexible-reverse-proxy
After global installation, you can use the flexible-proxy
command:
# Basic usage with routes
flexible-proxy --route "/api:http://localhost:3000" --route "/auth:https://auth.example.com"
# Custom port
flexible-proxy --port 3000 --route "/api:http://localhost:3000"
# Custom host and port
flexible-proxy --host 0.0.0.0 --port 8080 --route "/api:http://localhost:3000"
# Load routes from file
flexible-proxy --routes-file routes.json
# Watch routes file for changes and auto-reload
flexible-proxy --routes-file routes.json --watch
# Enable verbose logging
flexible-proxy --route "/api:http://localhost:3000" --verbose
# Different log levels
flexible-proxy --route "/api:http://localhost:3000" --log-level detailed
flexible-proxy --route "/api:http://localhost:3000" --log-level full
# Control header forwarding
flexible-proxy --route "/api:http://localhost:3000" --no-change-origin
flexible-proxy --route "/api:http://localhost:3000" --no-preserve-headers
# Show help
flexible-proxy --help
-p, --port <port>
- Port to listen on (default: 8000)-h, --host <host>
- Host to bind to (default: localhost)-r, --route <pattern:target>
- Add a route (pattern:target). Can be used multiple times--routes-file <file>
- Load routes from a JSON file--watch
- Watch routes file for changes and auto-reload--verbose
- Enable verbose logging--log-level <level>
- Log level: basic, detailed, full (default: basic)--preserve-headers
- Preserve all original headers (default: true)--no-preserve-headers
- Do not preserve original headers--change-origin
- Change the origin header to target host (default: true)--no-change-origin
- Do not change the origin header--version
- Show version--help
- Show helpThe proxy now features beautiful, colored logging with emojis and structured output:
🚀 Flexible Reverse Proxy Server
══════════════════════════════════════════════════
📍 Server running at http://localhost:8000
📊 Log level: detailed
🛣️ Routes configured:
/api → http://localhost:3000
/auth → https://auth.example.com
══════════════════════════════════════════════════
[2024-01-15T10:30:45.123Z] [abc123def456]
GET /api/users → http://localhost:3000
📋 Headers:
Authorization: Bearer token123
Content-Type: application/json
📦 Body: {"name": "John"}
[2024-01-15T10:30:45.125Z] [abc123def456]
200 OK
📋 Response Headers:
Content-Type: application/json
📦 Response Body: {"users": [...]}
[2024-01-15T10:30:45.125Z] [abc123def456]
❌ Proxy error: connect ECONNREFUSED
The proxy server forwards all headers to the target server by default. Here's how header handling works:
changeOrigin
is enabled)# Preserve all headers (default)
flexible-proxy --route "/api:http://localhost:3000" --preserve-headers
# Don't preserve headers
flexible-proxy --route "/api:http://localhost:3000" --no-preserve-headers
# Don't change the origin header
flexible-proxy --route "/api:http://localhost:3000" --no-change-origin
# Don't change the origin header and preserve all headers
flexible-proxy --route "/api:http://localhost:3000" --no-change-origin --preserve-headers
The proxy supports three logging levels with beautiful formatting:
Routes can be specified in two ways:
flexible-proxy --route "/api:http://localhost:3000" --route "/auth:https://auth.example.com"
Create a routes.json
file:
{
"/api": "http://localhost:3000",
"/auth": "https://auth.example.com",
"/static": "http://localhost:8080"
}
Then use it:
flexible-proxy --routes-file routes.json
You can also use the package programmatically:
const { createProxyServer } = require("flexible-reverse-proxy");
const routes = {
"/api": "http://localhost:3000",
"/auth": "https://auth.example.com",
};
const server = createProxyServer({
port: 8000,
host: "localhost",
routes: routes,
verbose: true,
logLevel: "detailed",
preserveHeaders: true,
changeOrigin: true,
});
server.start();
flexible-proxy --route "/api:http://localhost:3000"
flexible-proxy \
--route "/api:http://localhost:3000" \
--route "/auth:https://auth.example.com" \
--log-level detailed
flexible-proxy \
--route "/api:http://localhost:3000" \
--log-level full
# Forward all headers without changing origin
flexible-proxy \
--route "/api:http://localhost:3000" \
--no-change-origin \
--preserve-headers
# Minimal header forwarding
flexible-proxy \
--route "/api:http://localhost:3000" \
--no-preserve-headers
# routes.json
{
"/api": "http://localhost:3000",
"/auth": "https://auth.example.com"
}
# Command
flexible-proxy --routes-file routes.json --log-level detailed
# Start with file watching enabled
flexible-proxy --routes-file routes.json --watch
# The server will automatically reload routes when the file changes
# Edit routes.json and save - routes will update without restarting the server
Watch Mode Features:
# Clone the repository
git clone <repository-url>
cd reverse.proxy
# Install dependencies
npm install
# Run the server with example routes
npm start
# Or run the CLI locally
node bin/cli.js --route "/api:http://localhost:3000" --log-level detailed
npm publish
MIT
FAQs
A simple reverse proxy server with configurable routing
The npm package flexible-reverse-proxy receives a total of 29 weekly downloads. As such, flexible-reverse-proxy popularity was classified as not popular.
We found that flexible-reverse-proxy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.