MarmadileManteater / SimpleReverseProxy

A simple reverse proxy I threw together with actix-web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A simple actix-web reverse proxy

This is a simple 🕸actix-web server which 🗺maps subdomains to URIs. It accepts three arguments: path_to_cert, path_to_privkey, and path_to_map.json.

Here is an example JSON map which:

  • Maps requests with no sub-domain to a local server at the URI http://127.0.0.1:3000
  • Maps requests with sub-domains:
    • astro. to local filesystem URI file://astro which 👉points to ./public/astro
    • qwik. to local filesystem URI file://qwik which 👉points to ./public/qwik
    • yaytapi. to a local server at the URI http://127.0.0.1:8080

(Note: All filesystem URIs are use the ./public folder as the root: file:// -> ./public/)

{
  ".": {
    "protocol": "http",
    "uri": "127.0.0.1",
    "port": "3000"
  },
  "astro": {
    "protocol": "file",
    "uri": "astro"
  },
  "qwik": {
    "protocol": "file",
    "uri": "qwik"
  },
  "yaytapi": {
    "protocol": "http",
    "uri": "127.0.0.1",
    "port": "8080"
  }
}

⚒ Usage

Arguments

  1. Path to cert (required)
  2. Path to privkey (required)
  3. Path to proxy map (defaults to serving public/)
  4. Number of workers (defaults to 1)
./simple_rust_server path_to_cert.pem path_to_privkey.pem path_to_proxy_map.json 1

❗ Purpose

I started by trying to host a sveltekit server, and the solution I found for securing my server was just to use a reverse proxy, so I wrote this using a tutorial and an example for actix-web. This is also partially inspired by estk/Soxy.

You can see an instance of this server running by visiting any of these subdomains:

You can also see the GH action which deployed that server instance to linode here:

badge

About

A simple reverse proxy I threw together with actix-web


Languages

Language:Rust 97.8%Language:HTML 2.2%