Akasio is a simple HTTP server that redirects traffic based on a JSON redirect table. This is its Rust implementation.

Overview

This page is inaccurate and is pending updates.

Akasio (Rust)

Description

Akasio is a simple HTTP server that redirects traffic based on a JSON redirect table.

If you own a domain and wish to self-host a URL-shortening service, then this is the right tool for you.

Originally, Akasio is a backend server for website akas.io (akas stands for "also known as") written in Python and Flask. After rewriting the server with Golang, I decided to open-source it for anyone else that might be interested by it. It is both very easy to deploy and very easy to maintain, thanks to Golang's handy single-binary release (let's not talk about its size here).

Why Akasio

What can this be used for?

Personally, I find sending long URLs like https://gist.githubusercontent.com/k4yt3x/3b41a1a65f5d3087133e449793eb8858/raw to people pretty annoying, since you'll either have to copy and paste the whole URL or type the whole URL out. URL shorteners like Akasio solve this issue. All that's needed to be done to send such a long URL is just to create a new mapping in the redirect table (akas.io/z).

What are Akasio's benefits compared to services like bit.ly?

Akasio is self-hosted, and the redirect table is just a JSON file. This gives the users lots of flexibilities. The JSON file on the server can be symbolic-linked from a local workstation, updated by a front-end webpage, generated from a program, and so on.

Usages

This section covers Akasio's fundamental concepts, basic usages and setup guide.

Redirect Table

Akasio redirects incoming requests based on what's called a "redirect table". This table is essentially a JSON file with a simple source-to-target mapping. You can find an example akasio.json under the configs directory. By default, Akasio reads the redirect table from /etc/akasio.json.

{
    "/": "http://k4yt3x.com/akasio-rust",
    "/g": "https://github.com/k4yt3x",
    "/k4yt3x": "https://k4yt3x.com"
}

This example redirect table does the following mappings:

Taking the /g mapping for example, when a user visits https://yourwebsite.com/g, the user will be redirected to https://github.com/k4yt3x via a HTTP 301 (moved permanently) response.

URL Segments

When Akasio receives a request, it chops the request's path into segments, looks up the first segment against the redirect table, and returns the target URL + the rest of the segments joined with /.

For example, if the request URI is /segment1/segment2/segment3, the URI will be split into a string array with elements segment1, segment2, and segment3. Akasio will then lookup /segment1 within the redirect table and return redirected target URL + /segment2/segment3. If a / is not present at the end of the target URL, one will be appended automatically.

Continuing the example in the previous section, if the user visits https://yourwebsite.com/g/akasio-go, the user will be redirected to https://github.com/k4yt3x/akasio-go.

Website Setup

The recommended setup is to start Akasio as a service behind reverse proxy web server like Apache, Nginx or Caddy. You can find an example service file at configs/akasio.service.

A typical stand-alone setup process will look like the following.

  1. Build the akasio binary or download the akasio binary from releases (coming soon).
  2. Move the akasio binary to /usr/local/bin/akasio.
  3. Move the service file to /etc/systemd/system/akasio.service.
  4. Reload systemd with systemctl daemon-reload.
  5. Enable and start the service with systemctl enable --now akasio.
  6. Verify that the service has been started successfully via curl -v 127.0.0.1:8000.
  7. Configure front-end web server to reverse proxy to http://127.0.0.1:8000.

Binary Usages

The binary's usage is as following. You can also invoke akasio -h to see the usages.

Akasio Redirector 0.1.0
K4YT3X 
A simple Rust program that redirects HTTP requests.

USAGE:
    akasio-rust [FLAGS] [OPTIONS]

FLAGS:
    -d, --debug      enable debugging mode
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -b, --bind     binding IP address and port (IP:PORT)

The command below, for instance, launches Akasio, reads configurations from the file /etc/akasio.json, and serves domains akas.io and ffg.gg.

/usr/local/bin/akasio -r /etc/akasio.json -n akas.io -n ffg.gg

Running from Docker

Akasio is also available on Docker Hub. Below is an example how you can run Akasio with Docker. Be sure to create the redirect table and change the redirect table's path in the command below. You'll also need to change the server's hostname.

docker run -it -p 8000:8000 -v $PWD/akasio.json:/etc/akasio.json -h akasio --name akasio k4yt3x/akasio-go:1.1.1 -n akas.io

docker run -it \                                            # interactive
           -p 8000:8000 \                                   # bind container port to host's port 8000
           -v $PWD/akasio.json:/etc/akasio.json \           # bind mount host's akasio.json file under the current directory to container's /etc/akasio.json
           -h akasio \                                      # set container hostname akasio
           --name akasio \                                  # set container name akasio
           k4yt3x/akasio-go:1.1.1 \                         # container name
           -n akas.io                                       # listening hostnames

After spinning the container up, you can verify that it's running correctly by making a query with curl or any other tool of your preference.

Building From Source

The following commands will build Akasio binary at bin/akasio.

git clone https://github.com/k4yt3x/akasio-rust.git
cd akasio-go
cargo build

After building, you may also use sudo make install to install akasio to /usr/local/bin/akasio.

You might also like...
Operator is a web server. You provide a directory and Operator serves it over HTTP.
Operator is a web server. You provide a directory and Operator serves it over HTTP.

Operator Operator is a web server. You provide a directory and Operator serves it over HTTP. It serves static files the way you'd expect, but it can a

JSON Web Token implementation in Rust.

Frank JWT Implementation of JSON Web Tokens in Rust. Algorithms and features supported HS256 HS384 HS512 RS256 RS384 RS512 ES256 ES384 ES512 Sign Veri

simple static file server written in Rust based on axum framework

static-server simple static file server written in Rust based on axum framework I'm learning Rust and axum. My thought is simple. axum has a static-fi

service_policy_kit is a Rust based toolkit for verifying HTTP services against policies.
service_policy_kit is a Rust based toolkit for verifying HTTP services against policies.

Service Policy Kit service_policy_kit is a Rust based toolkit for verifying HTTP services against policies. You can: Build a complete testing framewor

Live Server - Launch a local network server with live reload feature for static pages

Live Server - Launch a local network server with live reload feature for static pages

Static Web Server - a very small and fast production-ready web server suitable to serve static web files or assets
Static Web Server - a very small and fast production-ready web server suitable to serve static web files or assets

Static Web Server (or SWS abbreviated) is a very small and fast production-ready web server suitable to serve static web files or assets.

VRS is a simple, minimal, free and open source static web server written in Rust
VRS is a simple, minimal, free and open source static web server written in Rust

VRS is a simple, minimal, free and open source static web server written in Rust which uses absolutely no dependencies and revolves around Rust's std::net built-in utility.

Simple and fast web server

see Overview Simple and fast web server as a single executable with no extra dependencies required. Features Built with Tokio and Hyper TLS encryption

An HTTP library for Rust

hyper A fast and correct HTTP implementation for Rust. HTTP/1 and HTTP/2 Asynchronous design Leading in performance Tested and correct Extensive produ

Releases(2.0.0)
Owner
K4YT3X
所謂的正確之物會隨人們各自的意志而遷移無常。| The so-called correctness will change with people's will.
K4YT3X
Simple http server in Rust (Windows/Mac/Linux)

How it looks like? Screenshot Command Line Arguments Simple HTTP(s) Server 0.6.1 USAGE: simple-http-server [FLAGS] [OPTIONS] [--] [root] FLAGS:

LinFeng Qian 788 Dec 28, 2022
OxHTTP is a very simple synchronous HTTP client and server

OxHTTP is a very simple synchronous implementation of HTTP 1.1 in Rust. It provides both a client and a server.

Oxigraph 13 Nov 29, 2022
Low level HTTP server library in Rust

tiny-http Documentation Tiny but strong HTTP server in Rust. Its main objectives are to be 100% compliant with the HTTP standard and to provide an eas

null 785 Dec 29, 2022
Completely OBSOLETE Rust HTTP library (server and client)

OBSOLETION NOTICE This library is DEAD. It was a useful experiment and is now being replaced under the scope of the Teepee (experimentation grounds at

Chris Morgan 390 Dec 1, 2022
Archibald is my attempt at learning Rust and writing a HTTP 1.1 web server.

Archibald To be a butler, is to be able to maintain an even-temper, at all times. One must have exceptional personal hygiene and look sharp and profes

Daniel Cuthbert 4 Jun 20, 2022
Host These Things Please - a basic http server for hosting a folder fast and simply

http Host These Things Please - a basic HTTP server for hosting a folder fast and simply Selected features See the manpage for full list. Symlinks fol

thecoshman 367 Dec 23, 2022
Fully async-await http server framework

Saphir is a fully async-await http server framework for rust The goal is to give low-level control to your web stack (as hyper does) without the time

Richer Archambault 83 Dec 19, 2022
Node.js http server framework powered by Hyper native binding.

hnsjs POC project. Install this test package yarn add @hnsjs/core Support matrix node10 node12 node14 node15 Windows x64 ✓ ✓ ✓ ✓ Windows x32 ✓ ✓ ✓ ✓

LongYinan 18 Nov 23, 2022
RUSTENGINE is the high-assurance HTTP server.

RUSTENGINE Table of Contents RUSTENGINE Table of Contents About RUSTENGINE Inspiration with Rust Features Compares with Nginx Build & Run About this R

FUNNY SYSTEMS 10 Aug 27, 2021
A synchronous HTTP server built on hyper.

Astra Astra is a synchronous HTTP server built on top of hyper. use astra::{Body, Response, Server}; fn main() { Server::bind("localhost:3000")

Ibraheem Ahmed 23 Nov 27, 2022