Skip to content

Proxy to local service #288

@JosiahParry

Description

@JosiahParry

I'm working with Caddy right now but I'd like to move to a rust based solution that allows me to spawn new services as i need. I think pingora is the solution but am having a lot of trouble getting a minimal example running.

I'm trying to adapt the quickstart reverse proxy to work with a local service but am having no luck.

For example i have a local app running at 127.0.0.1:9000
image

I've modified the LoadBalancer so that it only calls the local service.

fn main() {
    let mut my_server = Server::new(None).unwrap();
    my_server.bootstrap();
    let r = SocketAddr::from_str("127.0.0.1:9000").unwrap();
    let upstreams = LoadBalancer::try_from_iter([r]).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();
}

However, when I run this I get a 502 in the browser and there is no messaging being printed to stdout as to why this might be.
image

Are there any examples that illustrate proxying to a local service?

Ideally, I'd have a struct that can represent the app / service that can spawn new instances based on demand on random ports by, I think, implementing the Service trait. but before that, i'd need to prove that pingora can even proxy to a local app.

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