Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@jifeon/http-proxy-rules
Advanced tools
http-proxy-rules
is an add-on module to the node-http-proxy library. It lets you define a set of rules to translate matching routes to target routes that the reverse proxy service will talk to on the client's behalf.
npm install http-proxy-rules --save
var http = require('http'),
httpProxy = require('http-proxy'),
HttpProxyRules = require('http-proxy-rules');
// Set up proxy rules instance
var proxyRules = new HttpProxyRules({
rules: {
'.*/test': 'http://localhost:8080/cool', // Rule (1)
'.*/test2/': 'http://localhost:8080/cool2/' // Rule (2)
},
default: 'http://localhost:8080' // default target
});
// Create reverse proxy instance
var proxy = httpProxy.createProxy();
// Create http server that leverages reverse proxy instance
// and proxy rules to proxy requests to different targets
http.createServer(function(req, res) {
// a match method is exposed on the proxy rules instance
// to test a request to see if it matches against one of the specified rules
var target = proxyRules.match(req);
if (target) {
return proxy.web(req, res, {
target: target
});
}
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('The request url and path did not match any of the listed rules!');
}).listen(6010, cb);
Given the object we used to initialize the HttpProxyRules
instance above, here are some examples of how sample url paths would be translated.
You can initialize a new http-proxy-rules
instance with the following options:
{
rules: {}, // See notes below
default: '' // (optional) if no rules matched, translate url path to specified default
}
The rules object contains a set of key-value pairs mapping a regex-supported url path to a target route. The module only tries to match the visited url path, and not the entire url, with a specified rule. The target route must include the protocol (e.g., http) and the FQDN. See the tests for examples of how incoming route url paths may be translated with the use of this module.
(?:\\W|$)
is appended to the end of the regex-supported url path, so that if there is a key like .*/test
in the rules, the module matches paths /test
, /test/
, /test?
but not /testing
.FAQs
A proxy rules add-on to the node-http-proxy module.
The npm package @jifeon/http-proxy-rules receives a total of 113 weekly downloads. As such, @jifeon/http-proxy-rules popularity was classified as not popular.
We found that @jifeon/http-proxy-rules demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.