{"id":13564480,"url":"https://github.com/umputun/rlb","last_synced_at":"2025-03-17T11:30:39.435Z","repository":{"id":45184322,"uuid":"151977819","full_name":"umputun/rlb","owner":"umputun","description":"Redirecting Load Balancer","archived":false,"fork":false,"pushed_at":"2025-01-01T01:10:43.000Z","size":4177,"stargazers_count":41,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-27T23:06:01.360Z","etag":null,"topics":["http-proxy","http-redirect","load-balancer"],"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/umputun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-10-07T19:32:59.000Z","updated_at":"2025-01-01T01:10:40.000Z","dependencies_parsed_at":"2024-01-16T18:58:01.510Z","dependency_job_id":"1da4ac86-dac9-4ba6-b10d-5d613b4686b7","html_url":"https://github.com/umputun/rlb","commit_stats":{"total_commits":68,"total_committers":4,"mean_commits":17.0,"dds":0.07352941176470584,"last_synced_commit":"40a776dd286761a42be07b04176435e288f3bfe3"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umputun%2Frlb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umputun%2Frlb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umputun%2Frlb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umputun%2Frlb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umputun","download_url":"https://codeload.github.com/umputun/rlb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858056,"owners_count":20359271,"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","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":["http-proxy","http-redirect","load-balancer"],"created_at":"2024-08-01T13:01:32.009Z","updated_at":"2025-03-17T11:30:36.667Z","avatar_url":"https://github.com/umputun.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# RLB - Redirecting Load Balancer \n[![Build Status](https://github.com/umputun/rlb/workflows/build/badge.svg)](https://github.com/umputun/rlb/actions) [![Coverage Status](https://coveralls.io/repos/github/umputun/rlb/badge.svg)](https://coveralls.io/github/umputun/rlb) [![Go Report Card](https://goreportcard.com/badge/github.com/umputun/rlb)](https://goreportcard.com/report/github.com/umputun/rlb) [![Docker Automated build](https://img.shields.io/docker/automated/jrottenberg/ffmpeg.svg)](https://hub.docker.com/r/umputun/rlb/)\n\nThis service redirects incoming `GET` and `HEAD` requests (with 302) to the upstream servers. \nServers picked up randomly, unhealthy boxes excluded dynamically.\n\n_Note: This is not a replacement for reverse proxy. All it does is HTTP redirect, not the real network proxying._\n\nTo visualise the redirected content popularity statistics, you can use [rlb-stats](https://github.com/umputun/rlb-stats).\n\n## Install\n\n1. Copy provided `docker-compose.yml`\n1. Make `rlb.yml` config for your service(s) (see `rlb-sample.yml` below in [Config file format](#config-file-format) section).\n1. Start container with `docker-compose up -d`\n\nThis will start rlb on port `:7070` by default and requests like `http://host/api/v1/jump/service1?url=/files/blah.mp3` will be redirected to the one of upstreams.\n\n## API\n\n* GET|HEAD `/api/v1/jump/\u003cservice\u003e?url=/blah/blah2.mp3` – returns 302 redirect to destination server\n* GET|HEAD `/\u003cservice\u003e?url=/blah/blah2.mp3` – same as above\n\n## Failback support (optional)\n\nThis allow to check the upstreams health for the requested resource and failback to a predefined servers if request fails. `failback` defined in the config file and in case if non-empty will add an additional `HEAD` request to the final URL. If request returns 200, the request will be passed to the upstream, if not - the result will be assembled from the `failback` + resource. I.e. if `failback` is `http://failback.com/` and resource is `/files/blah.mp3` then the final URL will be `http://failback.com/files/blah.mp3`.\n\n## Config file format\n\n```yaml\n# top level services\nservice1:\n    n1: # node id\n        server: http://n1.radio-t.com     # base url \n        ping: /rtfiles/rt_podcast480.mp3  # ping url to check node's health\n        method: HEAD                      # ping method, uses HEAD if nothing defined\n        weight: 1                         # relative weight of the node [1..n]   \n\n    n2:\n        server: http://n2.radio-t.com\n        ping: /rtfiles/rt_podcast480.mp3\n        method: HEAD\n        weight: 1\n\n    n3:\n        server: http://n3.radio-t.com\n        ping: /rtfiles/rt_podcast480.mp3\n        method: HEAD\n        weight: 5                         # this node will get 5x hits comparing to n1 and n2 \n\nservice2:\n    n1:\n        server: http://n1.radio-t.com\n        ping: /rtfiles/rt_podcast480.mp3\n        method: GET\n        weight: 1\n\n    n2:\n        server: http://n2.radio-t.com\n        ping: /rtfiles/rt_podcast480.mp3\n        method: GET\n        weight: 3\n\n    n3:\n        server: http://n3.radio-t.com\n        ping: /rtfiles/rt_podcast480.mp3\n        method: GET\n        weight: 1\n\nfailback: http://archives.radio-t.com/media\n```\n\n## Stats\n\nRLB does not implement any statistics internally but supports external service for requests like this:\n\n```go\n\ttype LogRecord struct {\n\t\tID       string    `json:\"id,omitempty\"` // uniuque id\n\t\tFromIP   string    `json:\"from_ip\"`      // source ip\n\t\tTS       time.Time `json:\"ts,omitempty\"` // timestamp\n\t\tFname    string    `json:\"file_name\"`    // requested file name\n\t\tServcie  string\t   `json:\"service\"`      // requested service\n\t\tDestHost string    `json:\"dest\"`         // picked destination node\n\t}\n```\n\nIf stats url defined in command line or environment, each redirect will also hit stats url (`POST`) with `LogRecord` in body.\n \n## Parameters\n\n```\nUsage:\n  main [OPTIONS]\n\nApplication Options:\n  -p, --port=    port (default: 7070) [$PORT]\n  -c, --conf=    configuration file (default: rlb.yml) [$CONF]\n  -r, --refresh= refresh interval (default: 30) [$REFRESH]\n  -t, --timeout= HEAD/GET timeouts (default: 5) [$TIMEOUT]\n  -s, --stats=   stats url [$STATS]\n      --dbg      debug mode [$DEBUG]\n\n```\n\n## Status\n\nRLB runs in production for several years and serves downloads from [radio-t](https://radio-t.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumputun%2Frlb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumputun%2Frlb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumputun%2Frlb/lists"}