{"id":31559429,"url":"https://github.com/amrsaber/redirector","last_synced_at":"2025-10-05T01:38:35.737Z","repository":{"id":42768868,"uuid":"510513559","full_name":"AmrSaber/redirector","owner":"AmrSaber","description":"Simple, lightweight, configurable reverse proxy for redirecting requests based on domain","archived":false,"fork":false,"pushed_at":"2025-04-06T20:09:43.000Z","size":141,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T20:31:17.932Z","etag":null,"topics":["backend","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AmrSaber.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.MD","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-04T22:00:48.000Z","updated_at":"2025-04-06T20:09:28.000Z","dependencies_parsed_at":"2024-10-18T21:52:10.973Z","dependency_job_id":null,"html_url":"https://github.com/AmrSaber/redirector","commit_stats":{"total_commits":65,"total_committers":1,"mean_commits":65.0,"dds":0.0,"last_synced_commit":"5ac87329740ca26eaa63ea46c69cb97232bc8a3c"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/AmrSaber/redirector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmrSaber%2Fredirector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmrSaber%2Fredirector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmrSaber%2Fredirector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmrSaber%2Fredirector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AmrSaber","download_url":"https://codeload.github.com/AmrSaber/redirector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmrSaber%2Fredirector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278399622,"owners_count":25980329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","reverse-proxy"],"created_at":"2025-10-05T01:38:27.055Z","updated_at":"2025-10-05T01:38:35.731Z","avatar_url":"https://github.com/AmrSaber.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Redirector\n\nSimple, light weight, configurable, special-purpose reverse proxy for handling redirection based on domain name, written in Go.\n\nRedirector enables you to redirect your traffic from a given domain to a URL (or domain) using simple configuration. You can configure whether or not you want the redirection to be permanent (for browser caching) and whether or not to preserve the path after redirection.\n\nRedirector also watches the configuration file for updates, so you do not need to restart the application on each configuration update (see [configuration watching](#configuration-watching) section below).\n\n## Install\n\n### From binaries\nYou can download the binaries from the [latest release](https://github.com/AmrSaber/redirector/releases) manually, or using bash\n\n```bash\n# Download binary from release\ncurl -o redirector -sSL https://github.com/amrsaber/redirector/releases/download/\u003cversion\u003e/redirector_\u003cos\u003e_\u003carch\u003e\n\n# Give execute permission\nchmod +x redirector\n\n# Execute\n./redirector start --file config.yaml\n```\n\n### Docker Image\nYou can use the application's docker image `ghcr.io/amrsaber/redirector` You can also download a specific version with image tag, available tags can be found [here](https://github.com/AmrSaber/redirector/pkgs/container/redirector).\n\nFor example\n\n```bash\ndocker run -p 8080:8080 ghcr.io/amrsaber/redirector:latest start --url https://url-to-config.com\n```\n\nOr using a file\n\n```bash\ndocker run -p 8080:8080 -v /path/to/config.yaml:/config.yaml ghcr.io/amrsaber/redirector:latest start --file /config.yaml\n```\n\n## Usage\n\n### Commands\n- `start`: starts the server, see more details below\n- `stop`: stops the server if it's running and returns \"OK\", otherwise returns error\n- `ping`: pings the server to make sure it's running and healthy, returns \"PONG\" if server is running, otherwise returns error\n- `version`: displays current version of redirector\n\nTo view commands and their documentation and flags, start the application with `--help`, `-h`, `help`, `h`, or without any commands. And you can use `--help` or `-h` with any command to view more details about it.\n\n### Loading Configuration\nYou can load configuration from different sources:\n\n- From file using `--file` flag then file name, e.g. `redirector --file config.yaml`\n- From URL using `--url` flag then URL, e.g. `redirector --url https://some-url.com/path/to/config`\n- From URL using `CONFIG_URL` environment variable: just set the env variable and start the application, e.g. `CONFIG_URL=https//some-url.com/some/path redirector`\n- From STDIN using `--stdin` flag, e.g. `cat config.yaml | redirector --stdin`\n\nThe application will print the final form of the parsed configuration after parsing them, the configuration will be validated for the right type and schema, any additional fields will be ignored.\n\nTo only print the parsed configuration provide the flag `--dry-run`, e.g. `redirector --file config.yaml --dry-run`.\n\nIn case you provide more that 1 source, the precedence is as follows: stdin, file, url, env variable.\n\n#### Configuration Watching\nIn case of providing the configuration from a file, the application will attempt to watch the file for changes and update the configuration automatically with after each change, if the file became invalid after an update, the application will keep the last valid parsed configuration.\n\nIn case of providing the configuration from a URL (using `--url` flag or the env variable), the application will attempt to refresh the configuration from the URL after `cache-ttl` time specified in the configuration file. If the application fails to refresh after the specified cache-ttl time (invalid config format, network problem, etc...) it will keep the last valid parsed configuration and attempt to refresh with each new request.\n\n#### HTTP Basic Auth\nYou can protect a redirect behind http basic auth using the `auth` field as described in the schema below.\n\nNotes:\n- if the username and password of the basic auth were sent through http, they could be intercepted by a hacker.\n- Browsers cache username and passwords for http basic auth, so in case it's intended for personal use only, make sure that you use incognito browsing if you are opening the url from someone else's device.\n\n### Configuration File\nThe configuration file is a yaml file having the following structure:\n\n```yaml\n# The port for the application to listen on\n# Default: 80\nport: 3000\n\n# Options for managing the cached configurations in case it's loaded from a URL\nurl-config-refresh:\n  # Cache time to live, will attempt to refresh the configuration after that time\n  # Available time units are (\"ns\" for nanosecond, \"us\" for microsecond, \"ms\" for millisecond, \"s\" for second, \"m\" for minute, \"h\" for hour)\n  # You can use fractions like 2h30m10s\n  # Default: \"6h\"\n  cache-ttl: 12h\n\n  # Whether to re-perform the mapping (from received request to target url) again after refresh\n  # Default: false\n  remap-after-refresh: true\n\n  # A list of domains to refresh when there is redirect miss/hit\n  # Any matching domain from this list, will overwrite refresh-on-hit and refresh-on-miss options\n  refresh-domains:\n    - # Domain name, can include wild cards just like redirects\n      # Required field, must be a valid domain name\n      domain: '*.amr-saber.io'\n\n      # Whether to refresh when there is a miss or a hit\n      # When set to \"hit\" and the domain name matches the refresh domain, acts as if refresh-on-hit is set for this request\n      # When set to \"miss\" and the domain name matches the refresh domain, acts as if refresh-on-miss is set for this request\n      # Required field, must be one of (hit, miss)\n      refresh-on: miss\n\n  # Whether to refresh or not when there was a matched redirect\n  # Default: false\n  refresh-on-hit: true\n\n  # Whether to refresh or not when there was no matched redirect\n  # Default: false\n  refresh-on-miss: true\n\n# Auth schemas to be used with redirects\nauth:\n  # Basic auth is the only support type of auth for now\n  basic-auth:\n    # Schema name. Can be anything\n    some-auth:\n      # Basic auth realm. Can be anything. \n      # Default: \"Restricted\"\n      realm: \"MyRealm\"\n\n      # Users defined within this schema. Each of them must have a non-empty username and password\n      # username cannot repeat across same basic-auth schema\n      users:\n        - username: user-1\n          password: 1234\n        - username: user-2\n          password: 5678\n\n    # You can have as many auth schemas as you want\n    some-other-auth:\n      realm: \"MyRealm\"\n      users:\n        - username: user-4\n          password: 1234\n        - username: user-5\n          password: 5678\n\n# Whether or not the application should send temp redirection, the application will send permanent redirection status if set to false\n# The browser will cache the result if the status is permanent redirect, resulting in faster redirection,\n# but slower invalidation in case you changed redirection target\n# Default: true\ntemp-redirect: false\n\n# The list of redirection rules\nredirects:\n  - # Will redirect traffic from this domain\n    # You can use * in place of domain sections, e.g. *.amr-saber.io, *.*.io, *.amr-saber.*, *.*.* will all match (subdomain.amr-saber.io)\n    # Required field, and must not contain protocol or port\n    from: subdomain.amr-saber.io\n\n    # Will redirect traffic to this URL\n    # Required field, and must be a valid URL; cannot contain a path if `preserve-path` option is true\n    to: https://google.com\n\n    # Whether or not to preserve the path when redirecting\n    # e.g. if set to true: subdomain.amr-saber.io/hello-world will redirect to https://google.com/hello-world\n    # if set to false: subdomain.amr-saber.io/hello-world will redirect to https://google.com\n    # Default: false\n    preserve-path: true\n\n    # You can specify if this is a temp redirect or not per each redirect, this will overwrite the global temp-redirect option\n    # Default: value of global `temp-redirect` field\n    temp-redirect: true\n\n    # Auth configuration, must be one of the schemas defined in `auth` global block\n    # If several basic-auth schemas are used, all of them must have the same realm\n    # If a username is repeated across several schemas, the last provided schema will take precedence\n    auth:\n      - some-auth\n      - some-other-auth\n\n  - from: *.amr-saber.io\n\n    # \"to\" can also contain *, in this case both \"to\" and \"from\" must have the same structure\n    # and will substitute the wildcard(s) part(s) from the corresponding parts from the \"from\" domain\n    # i.e. if \"to\" is *.x.z, \"from\" can be (a.b.c, a.*.c, a.b.*, *.*.*) but not b.c or a.b.c.d\n    # This is useful if you wish to redirect all subdomains to a new domain for example\n    # e.g. \"to\": (*.x.z) \"from\": (*.b.c) =\u003e request from (a.b.c) will be redirected to (a.x.z)\n    # This can -of course- be combined with all the other options (preserve-path, temp-redirect, auth, ...)\n    to: https://*.amrsaber.io\n```\n\n### Redirection Notes\nIn case the request comes from a domain that matches several redirection rules, redirector will redirect to the first exact match if it's found, otherwise, it will redirect ot the first match with wildcard.\n\n## Logging\nRedirector logs different events (like starting server, configuration parsing and update, received requests) to STDOUT, and logs errors and warnings to STDERR.\n\n## Bugs and Feature Requests\nIf you find any bug, or want to request any feature, feel free to [open a ticket](https://github.com/AmrSaber/redirector/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famrsaber%2Fredirector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famrsaber%2Fredirector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famrsaber%2Fredirector/lists"}