Git Product home page Git Product logo

proxy-6's Introduction

proxy

An HTTP proxy written with Node.js (think Squid)

Build Status

This is a fork of TooTallNate/proxy with updated deps.

This module provides standard "HTTP proxy" logic. You can script your own server using the proxy server API. Be sure to take a look at the "Examples" section below.

There is also a companion proxy(1) CLI tool, which spawns an HTTP(s) proxy server with the specified options.

You could think of proxy(1) as similar to some of the other popular open source HTTP proxy software:

Installation

Install with npm:

$ npm install proxy

If you would like to have the proxy(1) CLI program in your $PATH, then install "globally":

$ npm install -g proxy

Examples

Basic HTTP(s) proxy server

A basic HTTP(s) server with all the default options. All requests are allowed. CONNECT HTTP method works as well.

var http = require('http');
var setup = require('proxy');

var server = setup(http.createServer());
server.listen(3128, function () {
  var port = server.address().port;
  console.log('HTTP(s) proxy server listening on port %d', port);
});

CLI Tool Examples

The proxy(1) CLI tool can be used to spawn HTTP(s) proxy server instances with various options.

Port to bind to

Pass the -p/--port option to with a port number to specify a TCP port to bind to. Defaults to 3128 if none is specified.

$ proxy --port 8080

Custom Proxy-Authenticate command

Pass the -a/--authenticate switch with a command to execute when the client Proxy-Authorization header is given. This command determines whether or not the request is authorized based on the "exit code" of the command.

The relevant request authentication information is passed in as PROXY_AUTH_USERNAME, PROXY_AUTH_PASSWORD and PROXY_AUTH_SCHEME environment variables.

For example, to authorize "Basic" authentication with username "foo" and password "bar":

$ proxy --authenticate 'if \
    [ "$PROXY_AUTH_USERNAME" = "foo" ] && \
    [ "$PROXY_AUTH_PASSWORD" = "bar" ]; \
      then exit 0; \
    fi; \
    exit 1;'

License

(The MIT License)

Copyright (c) 2013 Nathan Rajlich <[email protected]>

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.

proxy-6's People

Contributors

michaelgoin avatar nataliewolfe avatar tootallnate avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.