Skip to content

Quickstart document silently fails on any version over v0.3. #827

@will-x86

Description

@will-x86

Describe the bug

Quickstart documentation uses v0.3, and suggests adding via:

async-trait="0.1"
pingora = { version = "0.3", features = [ "lb" ] }

If using any later version than v0.3 (i.e., v0.4...0.7) then the quick start example silently fails. ( as needs "openssl" feature)

Pingora info

Please include the following information about your environment:

Pingora version: anything post v0.4 ( tested with v0.3, v0.4 & v0.7
Rust version: cargo 1.93.1 (083ac5135 2025-12-15)
Operating system version: NixOS 26.05 (Yarara) x86_64

Steps to reproduce

use async_trait::async_trait;
use pingora::prelude::*;
use std::sync::Arc;

pub struct LB(Arc<LoadBalancer<RoundRobin>>);

#[async_trait]
impl ProxyHttp for LB {
    type CTX = ();
    fn new_ctx(&self) -> () {
        ()
    }
    async fn upstream_peer(&self, _session: &mut Session, _ctx: &mut ()) -> Result<Box<HttpPeer>> {
        let upstream = self
            .0
            .select(b"", 256) // hash doesn't matter for round robin
            .unwrap();

        println!("upstream peer is: {upstream:?}");

        // Set SNI to one.one.one.one
        let peer = Box::new(HttpPeer::new(upstream, true, "one.one.one.one".to_string()));
        Ok(peer)
    }
    async fn upstream_request_filter(
        &self,
        _session: &mut Session,
        upstream_request: &mut RequestHeader,
        _ctx: &mut Self::CTX,
    ) -> Result<()> {
        upstream_request
            .insert_header("Host", "one.one.one.one")
            .unwrap();
        Ok(())
    }
}
fn main() {
    let mut my_server = Server::new(None).unwrap();
    my_server.bootstrap();

    let upstreams = LoadBalancer::try_from_iter(["1.1.1.1:443", "1.0.0.1:443"]).unwrap();

    let mut lb = http_proxy_service(&my_server.configuration, LB(Arc::new(upstreams)));
    lb.add_tcp("0.0.0.0:6188");

    my_server.add_service(lb);

    my_server.run_forever();
}

Expected results

Expected curl output as such:

Image

Observed results

Image

Even running with RUST_LOG=TRACE no errors are logged.

Image

Additional context

Upon using the quickstart docs, I saw that the latest release was 0.7.0 & decided to run:

cargo add pingora --features lb 
cargo add async-trait

which lead to:

# XXXXXXX
[dependencies]
async-trait = "0.1.89"
pingora = { version = "0.7.0", features = ["lb", "openssl"] }

My initial debugging lead me to #61 which assumes it's an intentional 502 as 127... ( a non-existent proxy) is used in the later example in quick start docs.

Solution

Change quickstart docs to have:

pingora = { version = "0.7.0", features = ["lb", "openssl"] }

or

pingora = { version = "0.3.0", features = ["lb", "openssl"] }

Admittedly this is a niche use-case, but seems like something that as realistically happened to others.

pingora = { version = "0.3.0", features = ["lb"] }  # works

pingora = { version = "0.4.0", features = ["lb"] }  # doesn't work 
pingora = { version = "0.4.0", features = ["lb", "openssl"] }  # works

pingora = { version = "0.7.0", features = ["lb"] }  # doesn't work
pingora = { version = "0.7.0", features = ["lb", "openssl"]}  # works

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions