Closed JosiahParry closed 1 month ago
In short, CTX is a way to share the state of a single request across its own phases. Each request will have its own CTX. CTX are independent from each other across different requests.
On the other hand, the problem you described is a typical session stickiness problem in world of proxies. The most robust way to solve it is to use set-cookie
on the first request and read the cookie
header to tell which requests are from the same client.
Oh this is nifty! Thank you @eaufavor. Is set-cookie
a crate?
I mean https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie. There are probably some crates to help you create/parse the set-cookie/cookie headers.
This question has been stale for a week. It will be closed in an additional day if not updated.
This issue has been closed because it has been stalled with no activity.
I've created a
DashMap<>
that is used to fetch appropriate upstreams based in theupstream_peer()
method of the proxy. The upstream is an interactive SPA served locally (using shiny if you're curious). Ideally these are sticky sessions.I've noticed that when connecting to the session, there are a number of requests that are made by the apps to fetch assets eg javascript and css. Each one of these triggers a new
CTX
which is a bit surprising to me.In the
request_filter()
stage, I fetch the app based on the slug. A few challenges with this is that the request header only tells me the referrer path from the proxy's perspective so i might not choose the same backend that one is presently connected to. And secondly, sometimes the referrer seems to just be a file which is quite confusing.Is there a way so that the CTX is sticky? Or that I can determine where to send a request when the referer is the proxy? Please see the referer and URI from the log below
_
request_filter()
method _Pingora info
Please include the following information about your environment:
Pingora version: 0.2.0 Rust version: i.e. cargo 1.81.0-nightly Operating system version: MacOS M1 Sonoma
Expected results
I expect the referer to contain info about the service the request is coming from, or that requests from the upstream peer do not create a new CTX so that I can get the correct info from the initial CTX
Additional context
URI and referer from log
The last entry is an error because i pass
session.client_addr().unwrap()
to the HttpPeer which appears to be wrong