GithubHelp home page GithubHelp logo

my_gateway_demo5's Introduction

my-gateway-demo5

all-in-one网关,仅用一个端口将各式各样不同的服务开放出去

项目仅供学习

项目固定,除非改BUG,否则不再改变。

目标

  • 1.配置化
  • 2.安全性

yaml配置解析 redis集成

原理说明

  1. 通过请求所附带的cookie判断属于哪个服务,然后反向代理到指定的服务
  2. 通过iframe套/页面,然后通过上层页面去接收cookie,使得/页面的请求附带指定的cookie
  3. 通过redis来做权限管理,用于需要通过页面/invite.html?index=svr-gogs来输入邀请码的功能,邀请码的格式是:cxx-gogs_chatgpt, cxx 是用户唯一标识,gogs_chatgpt是允许他访问两个服务 gogs和chatpgt。all表示所有服务都许可。
  4. 邀请码验证成功之后,会增加相应的用户唯一标识到redis,1-cxx-gogs_chatgpt,日后用用户唯一标识来鉴别权限范围。
  5. 使用命令增加邀请码:
sadd InviteCodesKey cxx-gogs_chatgpt
sadd AllowUserKey 0-me-all
  1. cookie的过期时间是1年,但是会一直刷新,其实是永不过期
  2. 邀请码校验成功后,会通过邀请码生成用户ID,这个ID写入redis,后续每个请求都会去redis里对比一下用户ID是否存在。以此来进行安全校验。

概述

我自己在写的一个网关,通过路径前缀,仅用一个端口将各式各样不同的服务开放出去。 再套上全局统一的邀请码,做安全验证。用途是,通过一个端口就开放自己所搭建过的所有web服务 适合只有一个端口出网,而且服务自己用的用户

config里的密钥私钥都是测试生成的,后续要自己替换自己的,免的有安全问题。

代码之所以不分模块的原因:太简单了,分了各种模块会很难改

使用docker安装

安装方法在install文件夹里,提供了dockerfile和docker-compose.yaml,仅用这两个文件就可以了,直接docker-compose up -d就可以安装部署

邀请页

https://localhost:8083/static/invite.html?index=svr-gogs

参数index是邀请验证成功后的跳转路径

效果预览




my_gateway_demo5's People

Contributors

anarckk avatar

Stargazers

 avatar

Watchers

 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.