thomasw / djproxy

djproxy is a class-based generic view reverse HTTP proxy for Django.
MIT License
42 stars 15 forks source link

Add X-Forwarded-Prefix header to reverse proxies #13

Closed blaix closed 9 years ago

blaix commented 9 years ago

So the proxied app can know what path it's proxied at. This will allow it to do things like fix URLs in REST API responses.

@thomasw I thought this would work, and the test does pass, but when I install this to my local application that's using generate_routes, it's not sending the header. Any ideas?

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.01%) to 99.44% when pulling f192bd53eac5b316c3e542d23ba09e36d9aafdca on yola:x_forwarded_prefix into 2f137f6466649fe806b10bdcd7bbeb6b98a211a7 on thomasw:master.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.01%) to 99.44% when pulling f192bd53eac5b316c3e542d23ba09e36d9aafdca on yola:x_forwarded_prefix into 2f137f6466649fe806b10bdcd7bbeb6b98a211a7 on thomasw:master.

blaix commented 9 years ago

I'm pretty proud of that coverage increase.

thomasw commented 9 years ago

Since this is a non-standard header, this shouldn't be added to djproxy itself. I currently have an implementation that adds support for proxy middleware which enable arbitrary additions/deletions to headers and much more: https://github.com/thomasw/djproxy/compare/middleware?expand=1#diff-5707531655fb014a093e0475c9472d64R32

My branch also pulls a bunch of stuff that shouldn't have lived in the HttpProxy view into its own classes.

Good news: The existing test suite passes after the updates I've made. Bad news: I don't want to ship that just yet because the complexity of the test suite can be significantly reduced.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.01%) to 99.44% when pulling 6972e84cdde863dfcecd01bc9e10abeae0783163 on yola:x_forwarded_prefix into 2f137f6466649fe806b10bdcd7bbeb6b98a211a7 on thomasw:master.

blaix commented 9 years ago

d79369a4ac3aac9f0211bc61d5b16d8b2654907f fixes the issues I was having.

Good news: The existing test suite passes after the updates I've made. Bad news: I don't want to ship that just yet because the complexity of the test suite can be significantly reduced.

I can resubmit this after it ships (if you could comment on this issue when that point comes it would be great). In the meantime, we can use our fork. I'll close this pull.

coveralls commented 9 years ago

Coverage Status

Coverage increased (+0.01%) to 99.44% when pulling d79369a4ac3aac9f0211bc61d5b16d8b2654907f on yola:x_forwarded_prefix into 2f137f6466649fe806b10bdcd7bbeb6b98a211a7 on thomasw:master.

thomasw commented 9 years ago

I'll let you know. Hopefully I will have something out today.

thomasw commented 9 years ago

2.0.0 has shipped.