{"id":13520355,"url":"https://github.com/mirdaki/urshort","last_synced_at":"2025-03-31T16:31:17.968Z","repository":{"id":60166187,"uuid":"367700738","full_name":"mirdaki/urshort","owner":"mirdaki","description":"A blazingly fast and amazingly simple URL shortener designed for self-hosters.","archived":false,"fork":false,"pushed_at":"2022-09-28T05:17:20.000Z","size":81,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-24T18:55:04.361Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","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/mirdaki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-15T18:11:53.000Z","updated_at":"2022-12-25T22:57:39.000Z","dependencies_parsed_at":"2022-09-26T03:50:28.081Z","dependency_job_id":null,"html_url":"https://github.com/mirdaki/urshort","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirdaki%2Furshort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirdaki%2Furshort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirdaki%2Furshort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mirdaki%2Furshort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mirdaki","download_url":"https://codeload.github.com/mirdaki/urshort/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222670691,"owners_count":17020513,"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":[],"created_at":"2024-08-01T05:02:18.312Z","updated_at":"2024-11-02T03:31:21.980Z","avatar_url":"https://github.com/mirdaki.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# URShort\n\n[![Latest Docker Image Version][Docker Image]][Docker Download]\n[![Latest Crates.io Version][Crates Image]][Crates Download]\n[![Latest Crates.io Version][Build Image]][Build]\n[![MIT license][License Image]][License]\n\n[Docker Image]: https://img.shields.io/docker/v/mirdaki/urshort?style=flat-square\n[Docker Download]: https://hub.docker.com/r/mirdaki/urshort\n[Crates Image]: https://img.shields.io/crates/v/urshort?style=flat-square\n[Crates Download]: https://crates.io/crates/urshort\n[Build Image]: https://img.shields.io/github/workflow/status/mirdaki/urshort/Rust%20Check/main?style=flat-square\n[Build]: https://github.com/mirdaki/urshort/actions/workflows/rust-check.yml\n[License Image]: https://img.shields.io/crates/l/urshort?style=flat-square\n[License]: LICENSE.md\n\nA blazingly fast and amazingly simple URL shortener designed for self-hosters.\n\nSupport regular vanity URI mappings as well as (Perl style) regex based mapping!\n\nIt uses environmental variables to configure all matches and loads them into an in-memory model for near instant access! Designed for hosting with containers and for individual use.\n\n## Build\n\nUse the standard [Rust tools](https://www.rust-lang.org/tools/install). There is also a [Dev Container](https://code.visualstudio.com/docs/remote/create-dev-container) if you would prefer to run it that way.\n\n```bash\ncargo build\n\n# Also recommended for linting suggestions\ncargo clippy\n\n# And for consistent formatting\ncargo fmt\n```\n\nFor creating the Docker container. Use the included [Dockerfile](Dockerfile) and this:\n\n```bash\ndocker build -t urshort:latest .\n```\n\n## Installation\n\nIt is recommended to use [Docker](https://www.docker.com/) to use URShort:\n\n```bash\ndocker pull mirdaki/urshort\n```\n\nIf you have prefer, you can also install it via [cargo](https://doc.rust-lang.org/cargo/):\n\n```bash\ncargo install urshort\n```\n\nOr download directly from the [releases](https://github.com/mirdaki/urshort/releases).\n\n## Configuration\n\nAs all configuration is stored in environmental variables, it is recommenced to store them in an `.env` file for ease of tracking and updating. For example:\n\n```.env\nURSHORT_STANDARD_URI_test=https://example.com/\nURSHORT_STANDARD_URI_test2=https://example.com/2\n\nURSHORT_PATTERN_REGEX_0='^i(?P\u003cindex\u003e\\d+)$'\nURSHORT_PATTERN_URI_0='https://example.com/$index'\nURSHORT_PATTERN_REGEX_1='^(\\d+)$'\nURSHORT_PATTERN_URI_1='https://example.com/$1'\n```\n\n### Standard Mapping\n\nA standard vanity mapping would do something like: `hello -\u003e example.com/hello`\n\nUsing this config:\n- Path: `hello`\n- Redirect: `https://example.com/hello`\n\nThis is stored in a single environmental variable:\n\n```bash\n# \u003c\u003e is used to indicate the values to be changes\nURSHORT_STANDARD_URI_\u003cpath\u003e=\u003credirect\u003e\n\n# Actual example\nURSHORT_STANDARD_URI_test=https://example.com/\n```\n\nStandard mappings will override any regex mapping.\n\n### Regex Mapping\n\nA single regex pattern mapping could do something like:\n```\ni1 -\u003e example.com/1\ni42 -\u003e example.com/42\ni9001 -\u003e example.com/9001\n...\n```\n\nUsing this config:\n- Regex pattern: `'^i(?P\u003cindex\u003e\\d+)$'`\n- Pattern redirect `'https://example.com/$index'`\n\nThis is stored in two single environmental variables. The first contains\n```bash\n# \u003c\u003e is used to indicate the values to be changes\n# The first environmental variable determines the place in which the pattern is evaluated and the regex for that pattern\nURSHORT_PATTERN_REGEX_\u003cplace\u003e='\u003cregex\u003e'\n# The second environmental variable must match the place of the first and contains the pattern redirect\nURSHORT_PATTERN_URI_\u003cplace\u003e='\u003credirect\u003e'\n\n# Actual example\nURSHORT_PATTERN_REGEX_0='^i(?P\u003cindex\u003e\\d+)$'\nURSHORT_PATTERN_URI_0='https://example.com/$index'\n```\n\nBe sure to quote the values. Be careful with the order you have the mappings.\n\n### Port\n\nYou can specify a port the service will use. If not give, the default of `54027` will be used.\n\nThis is useful when running the service directly. If you use Docker, it is recommended to use the built in port mapping features instead of this.\n\nExample environmental variable: `URSHORT_PORT=7777`\n\n## Usage\n\nPlease use a web server, such as [Nginx](https://nginx.org/en/) or [Traefik](https://traefik.io/) in front of URShort.\n\n[Docker compose](https://github.com/docker/compose) is the recommended way to run URShort. An example file is [here](docker-compose.yaml). Load that file with your `.env` file and run:\n\n```bash\ndocker-compose up\n```\n\nYou can also use the Docker run command directly:\n\n```bash\ndocker run -d \\\n  --name=urshort \\\n  -p 54027:54027 \\\n  -e URSHORT_STANDARD_URI_test=https://example.com/ \\\n  -e URSHORT_PATTERN_REGEX_0='^i(?P\u003cindex\u003e\\d+)$' \\\n  -e URSHORT_PATTERN_URI_0='https://example.com/$index' \\\n  --restart unless-stopped \\\n  mirdaki/urshort:latest\n```\n\nOr if you have the bare executable, run `urshort` at the location of you `.env` file (or after your configuration is loaded directly into the environment).\n\n## Built With\n\nThank you to all the projects that helped make this possible!\n\n- [Rust](https://www.rust-lang.org/) for being an awesome language to build with\n- [Axum](https://github.com/tokio-rs/axum) for doing the whole URL redirect thing\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute to the project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirdaki%2Furshort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmirdaki%2Furshort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmirdaki%2Furshort/lists"}