What is the problem your feature solves, or the need it fulfills?
I'm new to pingora and I'm trying to do simple nginx replacement for my nuxt3 project. I don't know how to do Rust part of openssl. Can you tell me what I need to do in order to have https for my web app that is running on localhost:3000?
A clear and concise description of why this feature should be added. What is the problem? Who is
this for?
This is my code so far:
use async_trait::async_trait;
use pingora_core::server::Server;
use pingora_core::upstreams::peer::HttpPeer;
use pingora_core::Result;
use pingora_openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use pingora_proxy::{ProxyHttp, Session};
pub struct MyProxy {}
#[async_trait]
impl ProxyHttp for MyProxy {
type CTX = ();
fn new_ctx(&self) -> Self::CTX {
()
}
async fn request_filter(&self, session: &mut Session, _ctx: &mut Self::CTX) -> Result<bool> {
session
.req_header_mut()
.insert_header("Host", "127.0.0.1")
.unwrap();
Ok(false)
}
async fn upstream_peer(
&self,
_session: &mut Session,
_ctx: &mut Self::CTX,
) -> Result<Box<HttpPeer>> {
let addr = ("127.0.0.1", 3000);
let peer = Box::new(HttpPeer::new(addr, false, "127.0.0.1".to_string()));
Ok(peer)
}
}
fn main() {
env_logger::init();
let mut my_server = Server::new(None).unwrap();
my_server.bootstrap();
let mut acceptor = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap();
acceptor
.set_private_key_file("key.pem", SslFiletype::PEM)
.unwrap();
acceptor.set_certificate_chain_file("cert.pem").unwrap();
let acceptor = acceptor.build();
let mut my_proxy = pingora_proxy::http_proxy_service(&my_server.configuration, MyProxy {});
my_proxy.add_tcp("0.0.0.0:8888");
my_server.add_service(my_proxy);
my_server.run_forever();
}
I wanna be able to serve my apps with https and to learn how to do it.
Additional context
I am new to pingora and creating reverse proxies by myself but I've used Nginx and CaddyV2 in the past and I'm just trying to create simple demo that I can work with and learn from it by deploying on my EC2 instances with DNS that own.
What is the problem your feature solves, or the need it fulfills?
I'm new to pingora and I'm trying to do simple nginx replacement for my nuxt3 project. I don't know how to do Rust part of openssl. Can you tell me what I need to do in order to have https for my web app that is running on localhost:3000?
A clear and concise description of why this feature should be added. What is the problem? Who is this for? This is my code so far:
and my Cargo.toml:
Describe the solution you'd like
I wanna be able to serve my apps with https and to learn how to do it.
Additional context
I am new to pingora and creating reverse proxies by myself but I've used Nginx and CaddyV2 in the past and I'm just trying to create simple demo that I can work with and learn from it by deploying on my EC2 instances with DNS that own.
Thank you!