twisted / twisted/klein

How to use ProxyFix with klein?

Open
#723 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
838
Forks
123
Avg merge
7h 58m
Merged PRs (30d)
12

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Klein application object represented by my_klein_app and its app.run() entry point, then compare that integration with Werkzeug's ProxyFix documentation. Determine and document the supported way to process nginx's X-Real-IP and X-Forwarded-* headers without losing Klein's startup behavior; done means the client IP is logged correctly behind the reverse proxy.

Written by the indexing model from the issue text.

Assessment

Tech stack
nginx, python
Domain
api, backend
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.