Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proxy-chain

Package Overview
Dependencies
Maintainers
4
Versions
144
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxy-chain

Node.js implementation of a proxy server (think Squid) with support for SSL, authentication, upstream proxy chaining, and protocol tunneling.

  • 0.1.32
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
117K
increased by10.49%
Maintainers
4
Weekly downloads
 
Created

What is proxy-chain?

The proxy-chain npm package is used to create HTTP and HTTPS proxy servers with various functionalities such as proxy chaining, IP anonymization, and request logging. It is particularly useful for web scraping, testing, and other scenarios where you need to route requests through multiple proxies.

What are proxy-chain's main functionalities?

Creating a Basic Proxy Server

This code sample demonstrates how to create a basic proxy server using the proxy-chain package. The server listens on port 8000 and does not use an upstream proxy or request authentication.

const { ProxyChain } = require('proxy-chain');

const server = new ProxyChain.Server({
    port: 8000,
    prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
        return {
            upstreamProxyUrl: null,
            requestAuthentication: false,
        };
    },
});

server.listen(() => {
    console.log('Proxy server is listening on port 8000');
});

Chaining Proxies

This code sample shows how to set up a proxy server that chains requests through an upstream proxy. The upstream proxy URL is specified in the prepareRequestFunction.

const { ProxyChain } = require('proxy-chain');

const server = new ProxyChain.Server({
    port: 8000,
    prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
        return {
            upstreamProxyUrl: 'http://upstream-proxy.com:8080',
            requestAuthentication: false,
        };
    },
});

server.listen(() => {
    console.log('Proxy server is listening on port 8000 and chaining to upstream proxy');
});

IP Anonymization

This code sample demonstrates how to create a proxy server with IP anonymization. The anonymize option is set to true in the prepareRequestFunction.

const { ProxyChain } = require('proxy-chain');

const server = new ProxyChain.Server({
    port: 8000,
    prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
        return {
            upstreamProxyUrl: null,
            requestAuthentication: false,
            anonymize: true,
        };
    },
});

server.listen(() => {
    console.log('Proxy server is listening on port 8000 with IP anonymization');
});

Request Logging

This code sample shows how to log incoming requests to the proxy server. The prepareRequestFunction logs the hostname and port of each request.

const { ProxyChain } = require('proxy-chain');

const server = new ProxyChain.Server({
    port: 8000,
    prepareRequestFunction: ({ request, username, password, hostname, port, isHttp }) => {
        console.log(`Request to ${hostname}:${port}`);
        return {
            upstreamProxyUrl: null,
            requestAuthentication: false,
        };
    },
});

server.listen(() => {
    console.log('Proxy server is listening on port 8000 with request logging');
});

Other packages similar to proxy-chain

Keywords

FAQs

Package last updated on 08 Jun 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc