twisted/klein

How to use ProxyFix with klein?

laf0rge opened this issue · 1 comments

I'm running a klein based app behind a [nginx] reverse proxy which sets the various X-Real-IP, X-Forwarded-* headers. Klein doesn't automaticall seem to pick up on those, as the client IP logged is always the IP of the reverse proxy.

I saw there is https://werkzeug.palletsprojects.com/en/2.3.x/middleware/proxy_fix/ available for werkzeug, but I was unable to figure out how to use it. if I say something like

app = ProxyFix(my_klein_app, x_for=1, x_host=1)
app.run()

then the proxyFix of course doesn't offer the same run method like Klein.

Twisted should really provide this sort of functionality for Klein, given that we aren't running via WSGI.