You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to get the upstream IP address by getting the property upstream.address.
I am working with WASM filters written in Rust, so the code looks like:
use log::error;
use proxy_wasm::traits::*;
use proxy_wasm::types::*;
use std::str;
#[no_mangle]
pub fn _start() {
proxy_wasm::set_log_level(LogLevel::Info);
proxy_wasm::set_http_context(|_, _| -> Box<dyn HttpContext> { Box::new(HttpFilter) });
}
struct HttpFilter;
impl Context for HttpFilter{}
impl HttpContext for HttpFilter {
fn on_http_response_headers(&mut self, _: usize) -> Action {
// Add a header on the response.
let prop = self.get_property(["upstream", "address"].to_vec()).unwrap();
let addr = match str::from_utf8(&prop) {
Ok(v) => v,
Err(_e) => "",
};
error!("upstream address {}",addr);
Action::Continue
}
}
PS: Do not use that as production code. It is only an example.
I would like to create the docs about these properties, if possible.
I do not find any doc about how to fetch the remote IP address in WASM.
Many thx for your help.
The text was updated successfully, but these errors were encountered: