Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

The resource effective redirecting http server

License

NotificationsYou must be signed in to change notification settings

malafoss/no80

Repository files navigation

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 dohttp redirects than, for example, nginx. The docker image size is under one megabyte.

Using container image

Docker repository is available athttps://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 using301 and without-P option using302.

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 tohttps://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 tohttps://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 tohttps://siteA/pathA if request path matches with/match. Otherwise browsers are redirected tohttps://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 tohttps://siteA/pathA.Redirect paths starting with/starting such as/starting/mypath tohttps://siteB/pathB.Redirect paths starting with/redirect such as/redirect/mypath tohttps://siteC/pathC/mypath.Otherwise redirect by default tohttps://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 serviceAfter=docker.serviceRequires=docker.service[Service]TimeoutStartSec=0Restart=alwaysRestartSec=3ExecStartPre=-/usr/bin/docker stop no80ExecStartPre=-/usr/bin/docker rm no80ExecStartPre=/usr/bin/docker pull docker.io/malafoss/no80ExecStart=/usr/bin/docker run --rm --name no80 -p 80:80 docker.io/malafoss/no80 https://example.comExecStop=/usr/bin/docker stop no80[Install]WantedBy=multi-user.target

License

Copyright (c) 2022 Mikko Ala-Fossi

Licensed underMIT license


[8]ページ先頭

©2009-2025 Movatter.jp