The Django request URL becomes strange


I have a django project running on my localhost and it is working very well, however when I uploaded it to real server, some problem started happening with the url. it happens every time HttpResponseRedirect or any redirect gets called

a page on my local host

while on the server it becomes,

in firebug i see

GET signin,

I belive this happens because the has ^signin/$^ and APPEND_SLASH = True in because when I visit /signin/ it works!

404 page on my local host

Request URL:

on the server

Request URL:,

for some reason it is adding [comma][space] to url and redirects it.

home page is working without issues

The issue is tracked in the following ticket:

It has to do with how Django handles proxy redirection. The following middleware will help you out.

class MultipleProxyMiddleware(object):

    def process_request(self, request):
        Rewrites the proxy headers so that only the most
        recent proxy is used.
        for field in self.FORWARDED_FOR_FIELDS:
            if field in request.META:
                if ',' in request.META[field]:
                    parts = request.META[field].split(',')
                    request.META[field] = parts[-1].strip()

If, for example, your Django site is sitting behind a proxy which includes proxy information in the X-Forwarded-For header, and then your web server also does proxying, the header will contain a list (comma separated) of the proxied addresses. By using this middleware, it will strip all but one of the proxied addresses in the headers.