Code Monkey home page Code Monkey logo

edge-computing-resty's Introduction

Warning There's a more robust and complete solution available called lua-resty-dynacode

Edge computing resty

During our hackday, we created a simple edge computing platform using nginx, lua and rails. The ideas is to inject lua code into a running nginx through a CMS.

Demo

edge-computing-resty-demo-ffmpeg.mp4

Quick start

# running all the systems
make run
# open another tab - simulating a live colorbar live hls signal
make broadcast_tvshow

# you can check the streaming manifest content
http http://localhost:8080/hls/colorbar.m3u8

Go to http://localhost:3000/ and create a simple lua code to ensure a super secret token scheme:

local token = ngx.var.arg_token or ngx.var.cookie_superstition

if token ~= 'token' then
  return ngx.exit(ngx.HTTP_FORBIDDEN)
else
  ngx.header['Set-Cookie'] = {'superstition=token'}
end

A CMS print screen

# if you try to fetch the token again, the server will reply with a 403
http http://localhost:8080/hls/colorbar.m3u8

# but if you pass the super token, then it's going to work fine :)
http http://localhost:8080/hls/colorbar.m3u8?token=token

Future work

  • Federated functions
    • maybe using the domain to shard and sum with a global domain *
  • Some form of lua sandboxing
    • since luajit can't enforce quota, one might use the admin phase to run the code and mesure the time, check syntax, security?!
  • Provide a API hook for authentication
  • Publish it as a rock
  • Add measurements

edge-computing-resty's People

Contributors

leandromoreira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.