I wanted to ask you also if you could forward certain http headers to lemmy when it makes a request? Currently it doesnt forward them so lemmy thinks all the requests from mlmym to lemmy are from the docker ip its running on. And that makes it much harder to rate limit or ban bots since all requests are from the docker ip.
So basically, mlmym should preserve and forward X-Real-IP, X-Forwarded-For, X-Forwarded-Proto, and X-Forwarded-Host when proxying API/backend requests to Lemmy, because Lemmy uses these headers for correct client IP detection and rate limiting.
Something like this in the code where the incoming request is handled:
const forwardedFor = request.headers.get("x-forwarded-for");
const realIp =
request.headers.get("x-real-ip") ??
forwardedFor?.split(",")[0]?.trim();
const headers = new Headers(request.headers);
if (forwardedFor) {
headers.set("x-forwarded-for", forwardedFor);
}
if (realIp) {
headers.set("x-real-ip", realIp);
}
headers.set("x-forwarded-proto", request.headers.get("x-forwarded-proto") ?? "https");
headers.set("x-forwarded-host", request.headers.get("host") ?? "");
That would really help a lot and allow me and others to remove a lot of complicated workarounds for trying to get the source ip.