Giter Site home page Giter Site logo

dhr2's Introduction

Domain-based HTTP Redirect Ruleset (DHR2)

Domain-based HTTP Redirect Ruleset (DHR2) is a method that is using DNS to manage the redirects of HTTP requests. This is done by inserting special TXT records in the DNS configuration and point the domain to one or more DHR2 servers.

For example if you have the following dns configuration:

example.com    IN    TXT    "v=DHR2/1; l=http://www.iana.org/domains/example/"
example.com    IN    A      192.0.43.10

then the DHR2 server responds as follows:

> curl -Is http://example.com/
HTTP/1.1 302 Moved Temporarily
Location: http://www.iana.org/domains/example/
Connection: Keep-Alive

Using CNAME

DHR2 is CNAME compatible. This is done by having several rules on the domain name that the CNAME record is pointing to.

github.example.com    IN    CNAME    server.example.com

server.example.com    IN    A        192.0.43.10
server.example.com    IN    TXT      "v=DHR2/1; l=www.example.com"
server.example.com    IN    TXT      "v=DHR2/1; l=github.com; d=github.example.com"

This will result in:

> curl -Is http://server.example.com/ | grep Location
Location: http://www.example.com/

> curl -Is http://github.example.com/ | grep Location
Location: http://github.com/

Wildcard

To match multiple domains under one when using CNAME, you can use a wildcard.

github.example.com    IN    CNAME    server.example.com
any.example.com       IN    CNAME    server.example.com

server.example.com    IN    A        192.0.43.10
server.example.com    IN    TXT      "v=DHR2/1; l=www.example.com"
server.example.com    IN    TXT      "v=DHR2/1; l=www.github.com; d=github.example.com"
server.example.com    IN    TXT      "v=DHR2/1; l=google.com; d=*.example.com"

This will result in:

> curl -Is http://server.example.com/ | grep Location
Location: http://www.example.com/

> curl -Is http://github.example.com/ | grep Location
Location: http://github.com/

> curl -Is http://any.example.com/ | grep Location
Location: http://www.google.com/

dhr2's People

Contributors

tellnes avatar

Stargazers

Jørn Åne de Jong avatar  avatar Stanislav Tugovikov avatar Eugene Kalinin avatar Thomas Lindgren avatar

Watchers

 avatar  avatar

dhr2's Issues

URL rewriting using regular expressions

It would be nice to have a little more control over the destination URL. Apache already has a nice way of doing this with mod_rewrite which allows you to rewrite the URL using regular expressions.
If dhr2 would support this, it would be possible to for example send a user from www.example.com to web.myhostingprovider.ext/~example/

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.