Giter VIP home page Giter VIP logo

no80's Introduction

no80

no80 - The resource effective redirecting http server

No80 is a minimal dockerized http server that only makes redirects temporarily (302) or permanently (301) to given URLs. Often used to redirect http service users to a https service. A way more simple way to do http redirects than, for example, nginx. The docker image size is under one megabyte.

Using container image

Docker repository is available at https://hub.docker.com/r/malafoss/no80.

To run the latest container:

<docker|podman> run <DOCKER_OPTIONS> -p <PORT>:80 docker.io/malafoss/no80 <OPTIONS> <URL>

Options:

  -a           Append path from the http request to the redirected URL
  -h           Print this help text and exit
  -m PATH URL  Redirect path matching with PATH to URL
  -s PATH URL  Redirect path starting with PATH to URL
  -r PATH URL  Redirect path starting with PATH to URL appended with the rest of the path
  -p N         Use specified port number N (default is port 80)
  -P           Redirect permanently using 301 instead of temporarily using 302
  -q           Suppress statistics

With -P option, no80 will make permanent http redirects using 301 and without -P option using 302.

Example 1:

podman run -t -i --rm -p 8080:80 docker.io/malafoss/no80 https://example.com

Runs no80 http server which will redirect all port 8080 requests to https://example.com.

Example 2:

podman run -t -i --rm -p 8080:80 docker.io/malafoss/no80 -a https://example.com

Runs no80 http server which will redirect port 8080 requests having request path /path to https://example.com/path.

Example 3:

docker run --userns host --network host -t -i --rm docker.io/malafoss/no80 -a https://`hostname -f`

or

docker run -t -i --rm -p 80:80 docker.io/malafoss/no80 -a https://`hostname -f`

Redirect browsers accessing http port 80 to https port 443 on the current host.

Example 4:

podman run -t -i --rm -p 8080:80 docker.io/malafoss/no80 -m /match https://siteA/pathA https://siteB/pathB

Redirect browsers accessing http port 8080 to https://siteA/pathA if request path matches with /match. Otherwise browsers are redirected to https://siteB/pathB.

Example 5:

podman run -t -i --rm -p 8080:80 docker.io/malafoss/no80 -m /match https://siteA/pathA -s /starting https://siteB/pathB -r /redirect https://siteC/pathC https://siteD/pathD

Redirect exact path /match to https://siteA/pathA. Redirect paths starting with /starting such as /starting/mypath to https://siteB/pathB. Redirect paths starting with /redirect such as /redirect/mypath to https://siteC/pathC/mypath. Otherwise redirect by default to https://siteD/pathD.

Note that multiple -m, -s and -r options are allowed and are processed in the given order.

How to build?

To build: ./build.sh

To run tests: ./test.sh

How to run locally built image?

Running using docker (or similarly podman):

docker run -t -i --rm -p 8080:80 no80 https://example.com

How to run using systemd?

Running using systemd:

/etc/systemd/system/no80.service

[Unit]
Description=no80 http service
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
RestartSec=3
ExecStartPre=-/usr/bin/docker stop no80
ExecStartPre=-/usr/bin/docker rm no80
ExecStartPre=/usr/bin/docker pull docker.io/malafoss/no80
ExecStart=/usr/bin/docker run --rm --name no80 -p 80:80 docker.io/malafoss/no80 https://example.com
ExecStop=/usr/bin/docker stop no80
[Install]
WantedBy=multi-user.target

License

Copyright (c) 2022 Mikko Ala-Fossi

Licensed under MIT license

no80's People

Contributors

malafoss avatar

Stargazers

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