Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobymcbobs/url-redirector
A simple golang + yaml URL redirector
https://github.com/bobymcbobs/url-redirector
docker gitlab golang http kubernetes url url-shortener
Last synced: 2 months ago
JSON representation
A simple golang + yaml URL redirector
- Host: GitHub
- URL: https://github.com/bobymcbobs/url-redirector
- Owner: BobyMCbobs
- License: agpl-3.0
- Created: 2020-02-14T19:43:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-02-03T09:23:32.000Z (almost 3 years ago)
- Last Synced: 2023-03-12T04:03:16.346Z (almost 2 years ago)
- Topics: docker, gitlab, golang, http, kubernetes, url, url-shortener
- Language: Go
- Homepage: https://gitlab.com/BobyMCbobs/url-redirector
- Size: 117 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# url-redirector
> A simple cloud-native golang + yaml URL redirector app
## Features
- multi-host routes
- wildcard hosts
- root redirects
- wildcard paths
- simple YAML configuration
- restart-free configuration updating (only redeploy the ConfigMap)
- TLS/SSL support
- \>3MB container image## Config definitions
Example of `./config.yaml`
```yaml
'*':
routes:
a: https://about.gitlab.com
b: https://github.com
c: https://duckduckgo.com
root: https://reddit.com
wildcard: https://github.commyshortner1.com:
routes:
a: https://duckduckgo.com
b: https://reddit.com
c: https://github.com
root: https://about.gitlab.com
wildcard: https://github.commyshortner2.com:
routes:
a: https://about.gitlab.com
b: https://duckduckgo.com
c: https://github.com
root: https://reddit.com
wildcard: https://github.com
```Given the config above, if [`https://localhost:8080/duck`](https://localhost:8080/duck) is visited, the request will redirect to [`https://duckduckgo.com`](https://duckduckgo.com). If [`https://localhost:8080`](https://localhost:8080) is visited, the request will be redirected to [`https://gitlab.com`](https://gitlab.com). If the path that doesn't exist is visited, the request will be redirected to [`https://github.com`](https://github.com).
For more examples, check out [docs/EXAMPLES.md](docs/EXAMPLES.md)
## Local usage
```bash
docker run -it --rm -v "$PWD"/config.yaml:/app/config.yaml:z,ro -p 8080:8080 registry.gitlab.com/bobymcbobs/url-redirector:latest
```Note: arm64 images are available as _\*-arm64_ (e.g: _latest-arm64_, _1.4.0-arm64_, etc...)
## Building
```bash
docker build -t registry.gitlab.com/bobymcbobs/url-redirector:latest .
```## Deployment in k8s
Make sure you update the values in the yaml files
```bash
kubectl apply -f k8s-deployment/
```### Notes
- the ConfigMap can be updated at any time, give a few seconds for the patched version to be active## Environment variables
| Name | Purpose | Defaults |
| - | - | - |
| `APP_PORT` | the port and interface which the app serves from | `:8080` |
| `APP_PORT_TLS` | the port and interface which the app serves from | `:4433` |
| `APP_USE_TLS` | run the app with TLS enabled | `false` |
| `APP_TLS_PUBLIC_CERT` | the public certificate for the app to use | `server.crt` |
| `APP_TLS_PRIVATE_CERT` | the private cert for the app to use | `server.tls` |
| `APP_CONFIG_YAML` | the location of where the config.yaml is (for the [routes](#definitions)) | `./config.yaml` |
| `APP_USE_LOGGING` | toggle the saving of logs | `false` |
| `APP_LOG_FILE` | the location of where a log file will be created and written to | `./redirector.log` |## License
Copyright 2019-2021 Caleb Woodbine.
This project is licensed under the [AGPL-3.0](http://www.gnu.org/licenses/agpl-3.0.html) and is [Free Software](https://www.gnu.org/philosophy/free-sw.en.html).
This program comes with absolutely no warranty.