Opened 10 years ago

Closed 10 years ago

#3850 defect closed duplicate (duplicate)

bug in prePathURL breaks proxies (8.2.0)

Reported by: jamesyonan Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


Work around a bug in twisted 8.2.0 prePathURL function that breaks HTTP proxies by not properly respecting port numbers in Host:<port> style headers. As a result of the incorrect behavior, HTTP redirections fail if an HTTP proxy or IP-stack-level port forward rule remaps the port number of the request so that the port number in the Host header is different from the port number of the receiving transport.

For example, suppose I have a port forward rule on my server ( to redirect port 8443 on my public interface to where a twisted web server is listening. Now I connect with a web browser to and get this wrong redirect:


Of course, the bug is that twisted should have used port 8443 from the HTTP request instead of port 5000 from the transport to build the redirect. This bug will break any port-remapping proxy or forward rule.

I am submitting a patch as well to fix the issue.

Attachments (1)

prepath.patch (2.2 KB) - added by jamesyonan 10 years ago.

Download all attachments as: .zip

Change History (3)

comment:1 Changed 10 years ago by Jean-Paul Calderone

Resolution: duplicate
Status: newclosed

Hi jamesyonan. Thanks for coming back to file this. I noticed the problem earlier and filed this for you, #3845. Please attach your patch there. Thanks!

Changed 10 years ago by jamesyonan

Attachment: prepath.patch added

comment:2 Changed 8 years ago by <automation>

Owner: Glyph deleted
Note: See TracTickets for help on using tickets.