Code

Opened 7 years ago

Closed 6 years ago

#5592 closed (invalid)

HttpResponseRedirect dosen't work anymore with Squid Reverse Proxy

Reported by: lzanuz@… Owned by: nobody
Component: HTTP handling Version: master
Severity: Keywords: redirect reverse proxy squid
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

After changes os revision 6164 from django.http.init.py the method HttpResponseRedirect dosent works anymore with a Reverse Proxy. I have a Squid in frontend two Apache servers and the redirects don't work more after revision 6164. I'm using revision 6163 now :)
Thanks

Attachments (0)

Change History (8)

comment:1 Changed 7 years ago by mir

  • Keywords squid added
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I didn't test this, but this looks plausible enough.

comment:2 Changed 7 years ago by mir

lzanuz, can you add please information about your exact setup, like:

  • mod_python or what?
  • the relevant parts of the apache configuration (especially rewrite rules etc.)
  • the squid setup
  • how the redirects don't work (what do you get?)

comment:3 Changed 6 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

Yeah, we definitely need more information here. The change in [6164] makes us follow the HTTP spec correctly (previously we were not), so it's not really negotiable.

Closing for now, since it's been a month since the request for more information. Please reopen if you can provide more details about how to repeat the problem.

comment:4 Changed 6 years ago by anonymous

  • Resolution invalid deleted
  • Status changed from closed to reopened

comment:5 Changed 6 years ago by anonymous

After the revision 6164 django stoped to work
with a squid proxy reverse. I have a application
running in two server and a squid proxy making
load balance in front of the apaches:
I needed to make this path for squid work again
after the revison 6164.
Thanks


from django.core.handlers import base

def fix_location_header(request, response):

"""
Path for correct squid proxy reverse after django rev.6164.
---Removed---
if 'Location' in response and request.get_host():

responseLocation? = request.build_absolute_uri(responseLocation?)

"""
return response

base.fix_location_header = fix_location_header


comment:6 Changed 6 years ago by mtredinnick

No, that doesn't give us more information about how to repeat the problem. That just tells us what you changed to make it work with your particular -- completely unknown to us -- installation.

What are the relevant Squid configuration lines for example? What is an example of the HTTP response being sent across the wire that doesn't work?

As I mentioned above, we are now sending (or should be sending, barring some minor bug) correct Location headers. So I strongly suspect a configuration problem on your end somewhere. Try to capture the response that is causing the problem (use wireshark or something similar, for example). Try to replicate the problem in a small example. Print out the value of !responseLocation that we construct to see what it looks like.

Any of this would be information we could use to debug the problem further. Suggesting that we just remove the very line that fixes the bug is not information that helps anybody debug further.

comment:7 Changed 6 years ago by anonymous

Sorry, but I can't send the squid rules and full http wire, but I will send the specific part where is the error.

Hypertext Transfer Protocol
    HTTP/1.0 503 Service Unavailable\r\n
        Request Version: HTTP/1.0
        Response Code: 503
    Server: squid/2.6.STABLE16-20070912\r\n
    Date: Mon, 22 Oct 2007 20:09:04 GMT\r\n
    Content-Type: text/html\r\n
    Content-Length: 1209
    Expires: Mon, 22 Oct 2007 20:09:04 GMT\r\n
    X-Squid-Error: ERR_DNS_FAIL 0\r\n
    X-Cache: MISS from ucs\r\n
    X-Cache-Lookup: MISS from ucs:3028\r\n
    Via: 1.0 ucs:3028 (squid/2.6.STABLE16-20070912)\r\n
    Proxy-Connection: close\r\n

And the html returned in portuguese:

A URL solicitada nao pode ser recuperada
Na tentativa de recuperar a URL: http://backendpool/ucssis/
O seguinte erro foi encontrado:
    Incapaz de determinar o endereço IP atraves do nome do host backendpool 
O servidor DNS retornou:
    DNS Domain 'backendpool' is invalid: Host not found (authoritative). 
Isso significa que:
O cache foi incapaz de resolver o nome do host presente na URL.
Verifique se o endereço esta correto.
Generated Mon, 22 Oct 2007 20:09:04 GMT by ucs (squid/2.6.STABLE16-20070912)

My impression is that apache take this url "http://backendpool/ucssis/" and send it back to squid.

Thanks for your help until now!

comment:8 Changed 6 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from reopened to closed

So this is a configuration error on your side and the Squid error message is telling you exactly what the problem is. The domain name must be valid.

Django builds up the domain name from these HTTP headers (in this order; the first one present is the hostname):

  1. The "X-Forwarded-Host" HTTP header
  2. The "Host" HTTP header (Required in all HTTP/1.1 requests)
  3. The server name (if using the mod_python handler)

Somewhere (and I guess it's the ServerName directive in you Apache config), you're setting the name to backendpool. You have to fix that to make it something Squid can resolve.

This is not a Django bug.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.