Code Monkey home page Code Monkey logo

node-redirect's Introduction

node-redirect

Creates a server that redirects incoming traffic to another domain and tracks all the requests.

This server allows for a high volume of redirect codes. Redirect codes are created programatically.

Requirements

  • node
  • npm
  • mongodb

Installation

    npm install shortcode-redirect

You will need to have MongoDb installed as well; shortcodes database is serverd from mongodb

Configuration

In order to run the redirect application, you will need to modify the config.json with your redirection options.

{
  "port": 80,
  "redirects": {
    "localhost": {
      "code": 302,
      "lookup": true,
      "insert": {
        "sharedsalt": "my secret salt",
	"url": "/newshortcode"
      }			
    },
    "otherhost.com": {
      "host": "http://shopping.example.com",
      "keepurl": true
      "code": 302,
    },
    "*": {
      "host": "http://www.google.com",
      "code": 302
    }
  }
}

The "*" config is the catch all, every host not specified in the config will be redirected there.

The "localhost" entry has two variants;

Varient 1 -- This will take the shortcode from the url and redirect to a personalized url.

  • lookup: true/false, translated the short code to a destination url.
  • insert: allow the domain to be used for creating new shortcodes remotely. See example.py how to create and post new shortcodes.
    • sharedsalt: seret used to sign requests.
    • url: the url used for the post operation
  • code: the http code used for redirecting traffic.

Vatriant 2 -- A static mapping of one domain to another (i.e. no short codes, but just redirect)

  • host: The destination URL
  • keepurl: true/false, retrain the url part of the request, i.e. example.com/abc -> google.com/abc

Usage

Starting locally

node bin/server

Create an example shortcode;

python ./example.py

Now you can visit http://localhost/... to be redirected

Or specify a custom port on wich to run the server:

node bin/server --port=3000

node-redirect's People

Contributors

fgascon avatar pksunkara avatar sorenriise avatar

Watchers

 avatar James Cloos 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.