All Projects → k4yt3x → akasio-go

k4yt3x / akasio-go

Licence: GPL-3.0 License
Akasio is a simple HTTP server that redirects traffic based on a JSON redirect table.

Programming Languages

go
31211 projects - #10 most used programming language
Makefile
30231 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to akasio-go

cs
开箱即用的基于命令的消息处理框架,让 websocket 和 tcp 开发就像 http 那样简单
Stars: ✭ 19 (+58.33%)
Mutual labels:  http-server
WebRelay
A netcat-like utility for windows for transferring files and streams over HTTP with support for relaying through a remote host (via websocket), a webclient, and a shell extension. PRs welcome!
Stars: ✭ 29 (+141.67%)
Mutual labels:  http-server
static-web-server
A blazing fast and asynchronous web server for static files-serving. ⚡
Stars: ✭ 230 (+1816.67%)
Mutual labels:  http-server
Swiftly
Swiftly is an easy to use Qt/C++ web framework
Stars: ✭ 20 (+66.67%)
Mutual labels:  http-server
finch-demo
Introduction to Finch, a lightweight HTTP server library based on Twitter's Finagle.
Stars: ✭ 19 (+58.33%)
Mutual labels:  http-server
serville
Serville, the fast and easy HTTP API library for NodeJS.
Stars: ✭ 31 (+158.33%)
Mutual labels:  http-server
shorturl
Generic implementation for interacting with various URL shortening services in Go.
Stars: ✭ 82 (+583.33%)
Mutual labels:  shorturl
yasuser
Yet another self-hosted URL shortener. | 短域名
Stars: ✭ 17 (+41.67%)
Mutual labels:  shorturl
Kvpbase
Scalable, simple RESTful object storage platform, written in C#
Stars: ✭ 43 (+258.33%)
Mutual labels:  http-server
naboris
Simple, fast, minimalist http server for OCaml/ReasonML
Stars: ✭ 71 (+491.67%)
Mutual labels:  http-server
lazurite
A simple http server.
Stars: ✭ 17 (+41.67%)
Mutual labels:  http-server
oxen-storage-server
Storage server for Oxen Service Nodes
Stars: ✭ 19 (+58.33%)
Mutual labels:  http-server
crab
🦀 a simple web server
Stars: ✭ 18 (+50%)
Mutual labels:  http-server
kog
🌶 A simple Kotlin web framework inspired by Clojure's Ring.
Stars: ✭ 41 (+241.67%)
Mutual labels:  http-server
httoop
HTTOOP - a fully object oriented HTTP protocol library written in python
Stars: ✭ 15 (+25%)
Mutual labels:  http-server
toyhttpd
I/O 模型练手代码,分别使用阻塞式 I/O、select、poll 和 epoll 和 Java NIO 实现了简单的 HTTP Server
Stars: ✭ 43 (+258.33%)
Mutual labels:  http-server
EthernetWebServer
This is simple yet complete WebServer library for AVR, Portenta_H7, Teensy, SAM DUE, SAMD21/SAMD51, nRF52, STM32, RP2040-based, etc. boards running Ethernet shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Coexisting now with `ESP32 WebServer` and…
Stars: ✭ 118 (+883.33%)
Mutual labels:  http-server
malidate
A logging DNS and HTTP(S) server. Opensource alternative to some parts of the Burpsuite Collaborator server.
Stars: ✭ 31 (+158.33%)
Mutual labels:  http-server
couper
Couper is a lightweight API gateway designed to support developers in building and operating API-driven Web projects
Stars: ✭ 60 (+400%)
Mutual labels:  http-server
DeepfakeHTTP
DeepfakeHTTP is a web server that uses HTTP dumps as a source for responses.
Stars: ✭ 373 (+3008.33%)
Mutual labels:  http-server

Akasio (Golang)

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-go",
    "/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.
  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.

Usage:
  -b string
        binding address (IP:port) (default "127.0.0.1:8000")
  -d    enable debugging mode, which disables security checks
  -n value
        server hostname, can be specified multiple times
  -r string
        redirect table path (default "/etc/akasio.json")
  -v    print Akasio version and exit

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-go.git
cd akasio-go
make

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].