<div dir="ltr">Thanks, I will study tickets you mentioned and hopefully fix it.<div>Quick-n-dirty fix gave me only two failed tests and in both cases it seems to be a wrong assumption in tests. So I hope this change won't break the world.</div><div><br></div><div>-- ilya<br><br><div class="gmail_quote"><div dir="ltr">вт, 14 мар. 2017 г. в 10:12, Glyph Lefkowitz <<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Mar 13, 2017, at 11:01 PM, Ilya Skriblovsky <<a href="mailto:ilyaskriblovsky@gmail.com" class="gmail_msg" target="_blank">ilyaskriblovsky@gmail.com</a>> wrote:</div><br class="m_-3306553942595082654Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg"><div class="gmail_msg">Hi,</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I'm using Twisted Web server behind Nginx reverse-proxy and I'm getting backend's internal host:port from Request.getHost().</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Seems like Request.host is explicitly set to socket's address (i.e. internal address) here: ​<a href="https://github.com/twisted/twisted/blob/trunk/src/twisted/web/http.py#L838" class="gmail_msg" target="_blank">https://github.com/twisted/twisted/blob/trunk/src/twisted/web/http.py#L838</a> But comment at ​<a href="https://github.com/twisted/twisted/blob/trunk/src/twisted/web/http.py#L1297" class="gmail_msg" target="_blank">https://github.com/twisted/twisted/blob/trunk/src/twisted/web/http.py#L1297</a> and what this method does points that Request.host meant to reflect Host header of the request, i.e. user-visible hostname and port.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This creates problems for me when using Klein because it correctly uses Request.getHost() to create host part of URLs for redirects.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It seems like inconsistency in Twisted code. I'd expect Request.host should be only set from the Host request header to reflect user-visible hostname, not the internal backend server's address. Or may be I'm missing something?</div></div></div></blockquote></div><div class="gmail_msg"><br class="gmail_msg"></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">You're absolutely correct!  I even filed a ticket for this functionality, 5 years ago: <a href="https://twistedmatrix.com/trac/ticket/5807" class="gmail_msg" target="_blank">https://twistedmatrix.com/trac/ticket/5807</a>  There's even a branch for it.  Oddly enough we <i class="gmail_msg">do</i> have a <i class="gmail_msg">private</i> _XForwardedForRequest, but... it's only used for logging, for some reason.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">If you want accurate access logging and request information, <a href="https://twistedmatrix.com/trac/ticket/7704" class="gmail_msg" target="_blank">https://twistedmatrix.com/trac/ticket/7704</a> will probably also be of interest to you.</div><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_msg"><div class="gmail_msg">I'm so sorry you've hit this glaring deficiency in Twisted.</div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div><div class="gmail_msg">On the other hand: I'm so glad that you've hit this glaring deficiency in Twisted!  I hope you will be motivated to fix it :-).  It's bothered me for quite some time that we don't play nicely with proxying setups, when such setups are so <i class="gmail_msg">incredibly</i> common.  If you can write pull requests to fix these issues and put them into review, I'm pretty sure you will find an enthusiastic reviewer quickly.</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">-glyph</div></div>_______________________________________________<br class="gmail_msg">
Twisted-web mailing list<br class="gmail_msg">
<a href="mailto:Twisted-web@twistedmatrix.com" class="gmail_msg" target="_blank">Twisted-web@twistedmatrix.com</a><br class="gmail_msg">
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" rel="noreferrer" class="gmail_msg" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br class="gmail_msg">
</blockquote></div></div></div>