cloudflare / pingora

A library for building fast, reliable and evolvable network services.
Apache License 2.0
20.3k stars 1.1k forks source link

Adding Host headers via arguments and route to upstream according to headers. #152

Closed muhammadn closed 3 months ago

muhammadn commented 3 months ago

I am writing a load balancer that configures dynamically configure upstream and host headers.

Looking at here: https://github.com/cloudflare/pingora/issues/134 which is similar but is based on url paths.

If for example i want to support multiple Host http header, i want to route to specific upstream servers for each requests with the Host header.

I was hoping some documentation that helps me achieve that. My source code is at https://github.com/muhammadn/projectlb

vicanso commented 3 months ago

I use pingora for my reverse proxy, you can look at the source code of upstream_peer: https://github.com/vicanso/pingap/blob/main/src/proxy/server.rs#L336

graph TD;
    start("New Request")-->server;

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

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

    locationA -- "10.0.0.1:8001" --> upstreamA1

    locationA -- "10.0.0.2:8001" --> upstreamA2

    locationB -- "10.0.0.1:8002" --> upstreamB1

    locationB -- "10.0.0.2:8002" --> upstreamB2
github-actions[bot] commented 3 months ago

This question has been stale for a week. It will be closed in an additional day if not updated.

github-actions[bot] commented 3 months ago

This issue has been closed because it has been stalled with no activity.