
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
http-proxy-no-line-184-error
Advanced tools
A full-featured http reverse proxy for node.js, minus that error.
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.
curl http://npmjs.org/install.sh | sh
npm install http-proxy
There are several ways to use node-http-proxy; the library is designed to be flexible so that it can be used by itself, or in conjunction with other node.js libraries / tools:
See the demo for further examples.
var http = require('http'), httpProxy = require('http-proxy'); // Create your proxy server httpProxy.createServer(9000, 'localhost').listen(8000); // Create your target server http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('request successfully proxied!' + '\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9000);
var http = require('http'), httpProxy = require('http-proxy'); // create a proxy server with custom application logic httpProxy.createServer(function (req, res, proxy) { // Put your custom server logic here proxy.proxyRequest(9000, 'localhost'); }).listen(8000); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9000);
var http = require('http'), httpProxy = require('http-proxy'); // create a proxy server with custom application logic httpProxy.createServer(function (req, res, proxy) { // Wait for two seconds then respond: this simulates // performing async actions before proxying a request setTimeout(function () { proxy.proxyRequest(9000, 'localhost'); }, 2000); }).listen(8000); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9000);
var http = require('http'), httpProxy = require('http-proxy'); // create a regular http server and proxy its handler http.createServer(function (req, res) { // Create a new instance of HttProxy for this request // each instance is only valid for serving one request var proxy = new httpProxy.HttpProxy(req, res); // Put your custom server logic here, then proxy proxy.proxyRequest(9000, 'localhost', req, res); }).listen(8001); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('request successfully proxied: ' + req.url +'\n' + JSON.stringify(req.headers, true, 2)); res.end(); }).listen(9000);
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:
var options = { router: { 'foo.com': '127.0.0.1:8001', 'bar.com': '127.0.0.1:8002' } };
The above route table will take incoming requests to 'foo.com' and forward them to '127.0.0.1:8001'. Likewise it will take incoming requests to 'bar.com' 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:
var proxyServer = httpProxy.createServer(options); proxyServer.listen(80);
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:
var proxyServerWithForwarding = httpProxy.createServer(9000, 'localhost', { forward: { port: 9000, host: 'staging.com' } }); proxyServerWithForwarding.listen(80);
The forwarding option can be used in conjunction with the proxy table options by simply including both the 'forward' and 'router' properties in the options passed to 'createServer'.
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:
usage: node-http-proxy [options] All options should be set with the syntax --option=value options: --port PORT Port that the proxy server should run on --target HOST:PORT Location of the server the proxy will target --config OUTFILE Location of the configuration file for the proxy server --silent Silence the log output from the proxy server -h, --help You're staring at it
If you have a suggestion for a feature currently not supported, feel free to open a support issue. 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.
(The MIT License)
Copyright (c) 2010 Charlie Robbins, Mikeal Rogers, Fedor Indutny, & Marak Squires
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A full-featured http reverse proxy for node.js, minus that error.
The npm package http-proxy-no-line-184-error receives a total of 0 weekly downloads. As such, http-proxy-no-line-184-error popularity was classified as not popular.
We found that http-proxy-no-line-184-error demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.