Git Product home page Git Product logo

docker-web-redirect's Introduction

This Docker container listens on port 80 and redirects all web traffic permanently to the given target domain/URL.

Features

  • Lightweight: Uses only ~2 MB RAM on Linux
  • Keeps the URL path and GET parameters
  • Permanent redirect (HTTP 301)

Usage

Docker run

The target domain/URL is set by the REDIRECT_TARGET environment variable.
Possible redirect targets include domains (mydomain.net), paths (mydomain.net/my_page) or specific protocols (https://mydomain.net/my_page).

Example: $ docker run --rm -d -e REDIRECT_TARGET=mydomain.net -p 80:80 morbz/docker-web-redirect

Paths are retained

The URL path and GET parameters are retained. That means that a request to http://myolddomain.net/index.php?page=2 will be redirected to http://mydomain.net/index.php?page=2 when REDIRECT_TARGET=mydomain.net is set.

Permanent redirects

Redirects are permanent (HTTP status code 301). That means browsers will cache the redirect and will go directly to the new site on further requests. Also search engines will recognize the new domain and change their URLs. This means this image is not suitable for temporary redirects e.g. for site maintenance.

Docker Compose

This image can be combined with the jwilder nginx-proxy. A sample docker-compose file that redirects myolddomain.net to mydomain.net could look like this:

version: '3'
services:
  redirect:
    image: morbz/docker-web-redirect
    restart: always
    environment:
      - VIRTUAL_HOST=myolddomain.net
      - REDIRECT_TARGET=mydomain.net

docker-web-redirect's People

Contributors

morbz avatar

Watchers

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