Skip to content

A reverse proxy like nginx, built on pingora, simple and efficient.

License

Notifications You must be signed in to change notification settings

adammakowskidev/pingap

This branch is 574 commits behind vicanso/pingap:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4716848 · Jun 14, 2024
Jun 11, 2024
Jun 10, 2024
Jun 14, 2024
May 31, 2024
May 30, 2024
Jun 13, 2024
Jun 14, 2024
Jun 11, 2024
May 31, 2024
May 4, 2024
Jun 14, 2024
Jun 14, 2024
May 11, 2024
Mar 7, 2024
Jun 1, 2024
Jun 14, 2024
Jun 9, 2024
May 11, 2024
Jun 14, 2024
May 9, 2024
Apr 4, 2024

Repository files navigation

pingap

What is Pingap

A reverse proxy like nginx, built on pingora, simple and efficient.

中文说明

Feature

  • Filter location by host and path
  • Path rewrite with regexp
  • HTTP 1/2 end to end proxy
  • TOML base configuration, file or etcd storage
  • Hot realod or Graceful restart after the configuration is changed
  • Template for http access log
  • Admin Web UI configuration
  • Genrate TLS certificates from let's encrypt
  • Notification events: lets_encrypt, backend_status, diff_config, restart, etc.
  • Http proxy plugins: compression, static serve, limit, stats, mock, etc.
  • Statistics at different stages: upstream_connect_time, upstream_processing_time, compression_time, cache_lookup_time and cache_lock_time.

Start

Loads all configurations from /opt/pingap/conf and run in the background. Log appends to /opt/pingap/pingap.log.

RUST_LOG=INFO pingap -c=/opt/pingap/conf -d --log=/opt/proxy/pingap.log

Graceful restart

Validate the configurations, send quit signal to pingap, then start a new process to handle all requests.

RUST_LOG=INFO pingap -c=/opt/pingap/conf -t \
  && pkill -SIGQUIT pingap \
  && RUST_LOG=INFO pingap -c=/opt/pingap/conf -d -u --log=/opt/pingap/pingap.log

Auto restart

Watch the configurations, if one of them changes, graceful restart pingap.

RUST_LOG=INFO pingap -c=/opt/pingap/conf \
  && -a -d --log=/opt/pingap/pingap.log

Dev

# generate admin web asset
make build-web
make dev

Config

All toml configurations are as follows pingap.toml.

Proxy step

Loading
graph TD;
    server["HTTP Server"];
    locationA["Location A"];
    locationB["Location B"];
    locationPluginListA["Proxy Plugin List A"];
    locationPluginListB["Proxy Plugin List B"];
    upstreamA1["Upstream A1"];
    upstreamA2["Upstream A2"];
    upstreamB1["Upstream B1"];
    upstreamB2["Upstream B2"];
    locationResponsePluginListA["Response Plugin List A"];
    locationResponsePluginListB["Response Plugin List B"];

    start("New Request") --> server

    server -- "host:HostA, Path:/api/*" --> locationA

    server -- "Path:/rest/*"--> locationB

    locationA -- "Exec Proxy Plugins" --> locationPluginListA

    locationB -- "Exec Proxy Plugins" --> locationPluginListB

    locationPluginListA -- "proxy pass: 10.0.0.1:8001" --> upstreamA1

    locationPluginListA -- "proxy pass: 10.0.0.2:8001" --> upstreamA2

    locationPluginListA -- "done" --> response

    locationPluginListB -- "proxy pass: 10.0.0.1:8002" --> upstreamB1

    locationPluginListB -- "proxy pass: 10.0.0.2:8002" --> upstreamB2

    locationPluginListB -- "done" --> response

    upstreamA1 -- "Exec Response Plugins" --> locationResponsePluginListA
    upstreamA2 -- "Exec Response Plugins" --> locationResponsePluginListA

    upstreamB1 -- "Exec Response Plugins" --> locationResponsePluginListB
    upstreamB2 -- "Exec Response Plugins" --> locationResponsePluginListB

    locationResponsePluginListA --> response
    locationResponsePluginListB --> response

    response["HTTP Response"] --> stop("Logging");

Performance

CPU: M2, Thread: 1

Ping no accces log:

wrk 'http://127.0.0.1:6188/ping' --latency

Running 10s test @ http://127.0.0.1:6188/ping
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    67.10us   67.52us   4.63ms   99.53%
    Req/Sec    74.82k     2.57k   85.56k    92.57%
  Latency Distribution
     50%   69.00us
     75%   76.00us
     90%   83.00us
     99%  105.00us
  1504165 requests in 10.10s, 196.52MB read
Requests/sec: 148928.76
Transfer/sec:     19.46MB

More Performance

Rust version

Our current MSRV is 1.74

License

This project is Licensed under Apache License, Version 2.0.

About

A reverse proxy like nginx, built on pingora, simple and efficient.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 78.6%
  • TypeScript 20.7%
  • Other 0.7%