{"id":13549830,"url":"https://github.com/Makeshift/nginx-retry-proxy","last_synced_at":"2025-04-02T23:31:10.991Z","repository":{"id":45058366,"uuid":"435426467","full_name":"Makeshift/nginx-retry-proxy","owner":"Makeshift","description":"A customisable backup proxy server that helps Nginx retry connections to upstreams.","archived":false,"fork":false,"pushed_at":"2024-09-06T06:44:27.000Z","size":101,"stargazers_count":3,"open_issues_count":7,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-03T19:37:15.317Z","etag":null,"topics":["nginx","nodejs","proxy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Makeshift.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-12-06T09:02:22.000Z","updated_at":"2022-05-23T09:35:08.000Z","dependencies_parsed_at":"2024-01-13T16:24:16.296Z","dependency_job_id":"1e8de443-afb2-4f4d-8969-a37bc59821a3","html_url":"https://github.com/Makeshift/nginx-retry-proxy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Makeshift%2Fnginx-retry-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Makeshift%2Fnginx-retry-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Makeshift%2Fnginx-retry-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Makeshift%2Fnginx-retry-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Makeshift","download_url":"https://codeload.github.com/Makeshift/nginx-retry-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246910932,"owners_count":20853652,"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":["nginx","nodejs","proxy"],"created_at":"2024-08-01T12:01:26.025Z","updated_at":"2025-04-02T23:31:10.745Z","avatar_url":"https://github.com/Makeshift.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Nginx Retry Proxy\n\nInspired by [this Stackexchange question](https://superuser.com/questions/746028/configuring-nginx-to-retry-a-single-upstream-server), this is a very simple little webserver that acts as a backup for when Nginx is down, and auto-refreshes the page for you.\n\nIt refreshes the page by using Javascript. If the client you're using doesn't support Javascript, it's expected to retry the connection itself. The proxy will return a 504 by default (See Options to change this behaviour).\n\n## Getting Started\n\n### Docker\n\nThe recommended way to run this proxy is via Docker, like so:\n\n```bash\ndocker run -it makeshift27015/nginx-retry-proxy -p 8080:8080\n```\n\nSee the `docker-compose.yml` file for an example.\n\n### Not Docker\n\n```bash\ngit clone https://github.com/Makeshift/nginx-retry-proxy.git\ncd nginx-retry-proxy\nnpm install\nnpm start\n```\n\nSee Options below for information on env vars and args.\n\n### Nginx\n\nTo use this proxy with Nginx, simply add it as a backup to your upstream, where `nginx_upstream` refers to the service you're trying to proxy to, and `backup_proxy:8080` is where this proxy is running.\n\n```\nupstream upstream {\n  server nginx_upstream;\n\n  server backup_proxy:8080 backup;\n}\n\nserver {\n  listen        80 default_server;\n\n  location / {\n    proxy_pass    http://upstream;\n  }\n}\n```\n\nSee `default.conf` for the same as above. It gets dropped straight into `/etc/nginx/conf.d/default.conf`.\n\n## Options\n\n### Ports\n\nYou can optionally start on a port that isn't 8080 with `npm start 80` or any other port. You can also use the environment variable `PORT`.\n\n### Healthchecks\n\nBy default, the only request endpoint that doesn't result in a HTML document with some Javascript for a refresh is `/retry-proxy/healthcheck`, which returns a 200 OK.\n\nThis endpoint can be modified by providing the `HEALTHCHECK_PATH` env var. Eg `HEALTHCHECK_PATH=/different/healthcheck/endpoint`\n\nYou can also tell the proxy how many times since startup it should log out requests to the healthcheck path. For example, if `HEALTHCHECK_REPLIES=10` it will log out the first 10 requests send to `HEALTHCHECK_PATH`, then stop logging them.\n\nIf set to 0, it will always log out requests.\n\n### Return Code\n\nBy default, the proxy returns a `504 Gateway Timeout`, which is what Nginx also sends by default. This behaviour can be changed with the `RESPONSE_HTTP_CODE` env var.\n\n### Headers\n\nBy default, no additional headers are set (aside from those provided by default by [Fastify](https://www.fastify.io/)). This behaviour can also be changed, and additional headers can be added.\n\nA use-case for this is, for example, setting `RESPONSE_HTTP_CODE` to `301`, then you could set a header containing `Location: https://example.com/` to redirect the request.\n\nHeaders can be set with the `RESPONSE_HTTP_HEADERS` env var, and are comma separated. For example:\n```\nRESPONSE_HTTP_HEADERS=\"Location: http://backup.example.com, Cache-Control: no-cache\"\n```\n\nSee the `docker-compose.yml` file for examples. If extraneous quotes or spaces are added, it will try to parse them.\n\n### Response Content/Content-Type\n\nBy default, the response Content-Type is `text/html`. This can be changed with the `RESPONSE_TYPE` env var.\n\nThe default response text is: `The server you requested is down. Retrying...\u003cscript\u003esetTimeout(() =\u003e window.location.reload(), 5000);\u003c/script\u003e`.\n\nThis can be changed with the `RESPONSE_STRING` env var.\n\n## Tests\n\nTODO :(\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMakeshift%2Fnginx-retry-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMakeshift%2Fnginx-retry-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMakeshift%2Fnginx-retry-proxy/lists"}