Git Product home page Git Product logo

aws-url-redirector's Introduction

Universal cloud redirector

Motivation: replace Apache & Nginx rewrite rules and make them cloud and "business" friendly.

Key parts:

  • Cloudfront + Lambda@Edge
  • S3 Select to query rules and regexp.

How to setup

You can setup different rules:

  • simple rules (rules.csv)
  • complex rules (regexp.csv)

Complex rules are the fallback when a path is not found.

Other variables are available in setup.demo.json:

  • Cloudfront TTL
  • Bucket and files names
  • x-api-key to invalidate cache
  • a fake origin that never will be reached

You can have serveral DNS over a distribution, and rules and regexp are dependant on host domain.

Rules example format

host path redirect
xxxx.cloudfront.net /dev https://developer.mozilla.org/
subdomain.yourdomain.net /search https://www.google.com

Regexp example format

host regexp redirect
xxxx.cloudfront.net /directory?page=(.*) https://application.yourdomain/folder/folder1/?page=$1

Endpoints (cloudfront behaviors)

  • /{whatever} > it will search for {whatever} and the host requested into the CSV
    • first search is into simple rules csv. If not found, it maps query against regexp file.
    • regexp file is "cached" to avoid continuous S3Select queries. You can refresh it sending a POST request to your cloudfront endpoint withyour x-api-key
    • if a path is found, a 301 redirect is returned. If not, 404.
  • /invalidate/ --> POST. It will generate a invalidation request. Params
    • x-api-key: defined in setup.demo.json
    • x-invalidatepaths: a string containing the paths to invalidate, comma separated
  • /sign/ --> it will return a S3 signed form to upload a rules.csv file (not used at this time). Params:
    • x-api-key: defined in setup.demo.json

Notes

  • Distribution id has to be set manually in setup.demo.json after a first deploy of the stack...

Some tips about cloudfront and lambda@edge

aws-url-redirector's People

Contributors

davidayalas avatar

Watchers

 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.