[uWSGI] http proxying in response-route

mathieu lacage mathieu.lacage at alcmeon.com
Tue May 28 13:29:03 UTC 2019


I am trying to implement X-sendurl in my application using uwsgi. I
modified my app to generate a couple of http headers:

215         handler.response.headers['X-Sendurlhost'] = '%s:%d,%s' %
(socket.gethostbyname(url.hostname), url.port if url.port is not None else
80, url.hostname)
216         handler.response.headers['X-Sendurlpathqs'] = "%s?%s" %
(url.path, url.query)
217         handler.response.set_status(200)

and I configured my uwsgi server as follows:

 29 collect-header = X-Sendurlpathqs X_SENDURLPATHQS
 30 collect-header = X-Sendurlhost X_SENDURLHOST
 31 response-route-if-not = empty:${X_SENDURLPATHQS} goto:xsendurl
 32 response-route-run = last:


 45 response-route-label = xsendurl
 46 response-route-run = rewrite:${X_SENDURLPATHQS}
 48 response-route-run = http:${X_SENDURLHOST}
 49 response-route-run = last:

The above configuration appears to hit and execute correctly line 48 above

with the following values:


I read very carefully the documentation at
https://uwsgi-docs.readthedocs.io/en/latest/InternalRouting.html and I
would expect the above to forward an HTTP request to IP on
port 80 with HTTP header HOST=storage.gra3.cloud.ovh.net and

However, tcpdump shows instead the following request:

Host: localhost:9090

HTTP/1.1 401 Unauthorized
Content-Length: 131
Content-Type: text/html; charset=UTF-8
Www-Authenticate: Swift realm="8"
WWW-Authenticate: Keystone uri='https://auth.cloud.ovh.net/'

So, uwsgi is connecting to the right IP and port, but it's not sending what
I would expect for the HOST HTTP header and HTTP PATH.

Is there something I should adjust in my uwsgi configuration to make it
forward the Host+PATH headers I want ?

Mathieu Lacage <mathieu.lacage at alcmeon.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.unbit.it/pipermail/uwsgi/attachments/20190528/37f9a750/attachment.html>

More information about the uWSGI mailing list