Giter VIP home page Giter VIP logo

rust-http-proxy's Introduction

HTTP 代理

Rust

  • HTTP 协议的解析(包括请求和响应)
  • 请求过滤以及响应过滤 (防火墙作用)
  • 可配置的代理鉴权
  • 整合 iptables 实现透明代理 (参数开关)
  • 日志记录
  • 测试 (且集成到 GitHub Actions 中)
  • HTTPS Tunnel

运行

项目根目录运行即可, 注意 config.yml 亦在根目录下

# 运行
cargo run 

# 构建
cargo build  # debug 版本
cargo build --release 

配置文件介绍

server: 
    # 有关于代理鉴权
    auth: 
        enable: false  # 支持鉴权,否则下面的字段不会使用
        username: rust 
        password: proxy

# 需要被过滤的内容
deny:
    request:  # 针对请求过滤,可以有多个规则,每个规则都匹配才会过滤掉
      - 
        name: request_deny_1
        rule:  
          line: # 请求行中的数据
            methods: [POST, PUT]  # 请求方法,满足其一即可
            path:  # 请求路径,满足其一即可,支持正则匹配
              - /login
          headers:  # 请求头部,全部满足才会
            - 
              key: "Content-Type"
              value: "application/json"
      
        
    response: # 响应中的数据过滤,暂只对请求头部信息进行过滤,全匹配才能被过滤掉
        -
          name: response_deny_1
          rule: 
            headers:
              - 
                key: "Content-Type"
                value: "application/json"
              -
                key: "Access-Control-Allow-Credentials"
                value: "true"

转换成 json 格式如下

{
  "server": {
    "auth": {
      "enable": false,
      "username": "rust",
      "password": "proxy"
    }
  },
  "deny": {
    "request": [
      {
        "name": "request_deny_1",
        "rule": {
          "line": {
            "methods": ["POST", "PUT"],
            "path": ["/login"]
          },
          "headers": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      }
    ],
    "response": [
      {
        "name": "response_deny_1",
        "rule": {
          "headers": [
            {
              "key": "Content-Type",
              "value": "application/json"
            },
            {
              "key": "Access-Control-Allow-Credentials",
              "value": "true"
            }
          ]
        }
      }
    ]
  }
}

rust-http-proxy's People

Contributors

junhaideng 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.