Hello, thanks for packaging gunicorn. I am using gunicorn to deploy a tornado server using the tornado worker. Deployment is behind a proxy, so I need to activate xheaders in the tornado httpserver[1], and use --forwarded-allow-ips in gunicorn. In workers/gtornado.py, however, I see no way to set xheaders=True in the created tornado httpserver. This seems odd because in the traceback in this link there seems to be or have been code for it: https://github.com/benoitc/gunicorn/issues/783 I'll now try to explore workarounds, as this is making it impossible to deploy a tornado server with gunicorn behind a proxy :/ Enrico [1] https://www.tornadoweb.org/en/stable/httpserver.html#http-server
First (failed) attempt was using a python configuration with this hook: def post_worker_init(worker): worker.server.xheaders = True however, at the time the hook is called, worker.server is not filled, and it is only filled in the TornadoWorker.run() method, which does not terminate and so cannot be extended. There seem to be no obvious way to hook into tornado.httpserver.HTTPServer creation inside TornadoWorker. I found a non-obvious way, monkey patching tornado.httpserver.HTTPServer to default to xheaders=True: def post_worker_init(worker): import tornado.httpserver class XheadersServer(tornado.httpserver.HTTPServer): def __init__(self, *args, **kw): super().__init__(*args, **kw) self.xheaders = True tornado.httpserver.HTTPServer = XheadersServer This way it seems to work. Enrico
Hi Enrico, Ooh, how delightful. ;) Would you like me to forward this issue upstream or would you be able to do that? (I don't think this is something that Debian should change independent of upstream, at least unless there was some kind of disagreement over the fix…) Best wishes,
Enrico