Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/arbarwings/docker-web-redirect
Lightweight Docker image that redirects all web traffic to another domain/URL
https://github.com/arbarwings/docker-web-redirect
docker nginx proxy redirects
Last synced: 3 months ago
JSON representation
Lightweight Docker image that redirects all web traffic to another domain/URL
- Host: GitHub
- URL: https://github.com/arbarwings/docker-web-redirect
- Owner: Arbarwings
- Created: 2020-08-08T10:13:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-20T08:16:35.000Z (8 months ago)
- Last Synced: 2024-05-20T09:33:59.446Z (8 months ago)
- Topics: docker, nginx, proxy, redirects
- Language: Shell
- Homepage:
- Size: 11.7 KB
- Stars: 7
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Docker-Web-Redirect #
This Docker container listens (by default) on port 80 and redirects all web traffic permanently to the given target domain/URL.
_Hint: This repo was forked from https://github.com/MorbZ/docker-web-redirect._
## Features ##
- Nginx 1.26
- Lightweight: Uses only ~2 MB RAM on Linux
- Keeps the URL path and GET parameters
- Permanent redirect (HTTP 301)
- Image Size only ~25MB## Usage ##
### Docker run ###
The target domain/URL is set by the `REDIRECT_TARGET` environment variable.
The port may be changed to another port than 80 by the `PORT` environment variable.
Possible redirect targets include domains (`mydomain.com`), paths (`mydomain.com/my_page`) or specific protocols (`https://mydomain.com/my_page`).**Example (Listen on Port 80):** `$ docker run --rm -d -e REDIRECT_TARGET=mydomain.com -p 80:80 arbarwings/docker-web-redirect`
**Example (Listen on Port 8080):** `$ docker run --rm -d -e REDIRECT_TARGET=mydomain.com -e PORT=8080 -p 8080:8080 arbarwings/docker-web-redirect `
### Paths are retained ###
The URL path and GET parameters are retained. That means that a request to `http://myolddomain.com/index.php?page=2` will be redirected to `http://mydomain.com/index.php?page=2` when `REDIRECT_TARGET=mydomain.com` 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 ##
A sample docker-compose file that redirects any incomming domain to `mydomain.com` could look like this:```yaml
version: '3'
services:
redirect:
image: arbarwings/docker-web-redirect
restart: always
environment:
- REDIRECT_TARGET=mydomain.com
```### Build the image yourself ###
`$ docker build -t arbarwings/docker-web-redirect:latest .`### Source code ###
https://github.com/Arbarwings/docker-web-redirect