Django

Code

Ticket #8874 (closed: invalid)

Opened 2 years ago

Last modified 5 months ago

problem with URLs on FastCGI after update to 1.0

Reported by: kyprizel Assigned to: kyprizel
Milestone: 1.2 Component: Core framework
Version: SVN Keywords:
Cc: qingfeng@me.com Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

all URI resolve to root(/) after updating django from beta to 1.0-release. here is part of urls.py:

urlpatterns = patterns('',
    (r'^$', 'src.views.main_index'),
    (r'^feedback/$', 'src.views.feedback'),
    (r'^admin/(.*)', admin.site.root)
)

trying to access /feedback/ but always get result of 'src.views.main_index'.

Attachments

wsgi.patch (1.0 kB) - added by kyprizel on 09/04/08 08:38:49.
simple wsgi patch to solve problem
wsgi_r11339.diff (1.1 kB) - added by qingfeng on 07/29/09 11:04:15.
nginx.conf (1.1 kB) - added by qingfeng on 09/16/09 09:19:54.
nginx.conf
sina.conf (0.6 kB) - added by qingfeng on 09/16/09 09:20:17.
Django Application conf

Change History

09/04/08 07:35:33 changed by kyprizel

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

Request META:

DOCUMENT_URI 	'/feedback/'
GATEWAY_INTERFACE 	'CGI/1.1'
HTTP_ACCEPT 	'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
HTTP_ACCEPT_CHARSET 	'windows-1251,utf-8;q=0.7,*;q=0.7'
HTTP_ACCEPT_ENCODING 	'gzip,deflate'
HTTP_ACCEPT_LANGUAGE 	'ru,en-us;q=0.7,en;q=0.3'
HTTP_CONNECTION 	'keep-alive'
HTTP_HOST 	'testgost.com'
PATH_INFO 	u'/'
QUERY_STRING 	''
REDIRECT_STATUS 	'200'
REQUEST_METHOD 	'GET'
REQUEST_URI 	'/feedback/'
SCRIPT_NAME 	u'/feedback/'
SERVER_PROTOCOL 	'HTTP/1.1'
SERVER_SOFTWARE 	'nginx'
wsgi.errors 	<flup.server.fcgi_base.TeeOutputStream object at 0x877faec>
wsgi.input 	<flup.server.fcgi_base.InputStream object at 0x877f8ec>
wsgi.multiprocess 	True
wsgi.multithread 	False
wsgi.run_once 	False
wsgi.url_scheme 	'http'
wsgi.version 	(1, 0)

09/04/08 08:19:39 changed by kyprizel

I use nginx web server, configured to use the same PATH_INFO and SCRIPT_NAME, so http://code.djangoproject.com/ticket/8490 made problems for me. Is my config incorrect?

09/04/08 08:20:06 changed by kyprizel

  • owner changed from nobody to kyprizel.
  • status changed from new to assigned.

09/04/08 08:38:49 changed by kyprizel

  • attachment wsgi.patch added.

simple wsgi patch to solve problem

09/05/08 09:15:15 changed by kyprizel

  • has_patch set to 1.

09/07/08 05:14:41 changed by kyprizel

  • keywords deleted.
  • stage changed from Unreviewed to Design decision needed.

10/15/08 09:38:08 changed by qingfeng

  • cc set to qingfeng@me.com.
  • has_patch deleted.

Django+nginx+prefork is problem too

10/15/08 09:38:27 changed by qingfeng

  • has_patch set to 1.

10/23/08 21:13:59 changed by mtredinnick

I don't believe this patch is really fixing the root problem. It looks like it's forcing script name to an incorrect value and just kind of works by accident.

The real question here is why does script name have a value of feedback/? That looks like either a configuration bug or a bug in nginx or something. We need to understand that a bit better before working out a solution to this problem.

10/23/08 21:14:49 changed by mtredinnick

  • stage changed from Design decision needed to Accepted.

(Moving out of design decision needed, since this is either a bug or not. If it's a bug, we should fix it. There's no design decision needed, just a proper understanding and solution.)

07/29/09 11:04:15 changed by qingfeng

  • attachment wsgi_r11339.diff added.

07/29/09 11:05:02 changed by qingfeng

  • version changed from 1.0 to SVN.
  • milestone set to 1.2.

(follow-up: ↓ 12 ) 08/31/09 11:01:35 changed by qingfeng

  • status changed from assigned to closed.
  • resolution set to duplicate.

fixed #8490

(in reply to: ↑ 11 ) 09/16/09 08:21:41 changed by kmtracey

  • status changed from closed to reopened.
  • resolution deleted.

Replying to qingfeng:

fixed #8490

The fact the the fix for #8490 may have introduced this problem does not make this a dupe of #8490. Please leave #8490 closed and put info relevant to fixing this problem in this ticket, not there.

09/16/09 09:19:54 changed by qingfeng

  • attachment nginx.conf added.

nginx.conf

09/16/09 09:20:17 changed by qingfeng

  • attachment sina.conf added.

Django Application conf

09/16/09 09:22:18 changed by qingfeng

nginx+django project conf file:

http://code.djangoproject.com/attachment/ticket/8874/nginx.conf

http://code.djangoproject.com/attachment/ticket/8874/sina.conf

urls.py:

from django.conf.urls.defaults import *

urlpatterns = patterns('',
    (r'^hello/', 'demo.views.hello'),
)

demo/views.py

from django.http import HttpResponse

def hello(request):
    return HttpResponse("Hello")

Django 1.1 Test:

curl -I http://localhost/hello

Restuls:

HTTP/1.1 404 NOT FOUND
Server: nginx/0.7.62
Date: Wed, 16 Sep 2009 09:23:29 GMT
Content-Type: text/html
Connection: keep-alive

use new patch:

http://code.djangoproject.com/attachment/ticket/8874/wsgi_r11339.diff

curl -I http://localhost/hello

Results:

HTTP/1.1 200 OK
Server: nginx/0.7.62
Date: Wed, 16 Sep 2009 10:27:11 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: Cookie

10/27/09 13:15:27 changed by Exe

The correct config for nginx. If you uncomment commented strings you fall into very strange and scarry bugs(ex. RequestContext? will go down or url-tag will do strange things). I'm posting it here as I spent 4 days to catch all problems with fcgi and solutions in the internet didn't work for me.

    location / {
        #DO NOT INCLUDE include         /etc/nginx/fastcgi_params;
        fastcgi_param   QUERY_STRING      $query_string;
        fastcgi_param   REQUEST_METHOD    $request_method;
        fastcgi_param   REQUEST_URI       $request_uri;

        fastcgi_param   CONTENT_TYPE      $content_type;
        fastcgi_param   CONTENT_LENGTH    $content_length;

        #DO NO SET fastcgi_param   SCRIPT_NAME       $fastcgi_script_name;
        fastcgi_param   PATH_INFO         $uri;
        fastcgi_param   SERVER_PROTOCOL   $server_protocol;

        fastcgi_param   SERVER_NAME       $server_name;
        fastcgi_param   SERVER_PORT       $server_port;

        fastcgi_param   REMOTE_ADDR       $remote_addr;
        fastcgi_param   REMOTE_PORT       $remote_port;

        fastcgi_pass    unix:/home/exe_messir_net/tmp/fcgi.sock;
    }

02/19/10 23:04:13 changed by btmorex

It should at least be documented on perhaps the server configuration documentation page that you can't define both PATH_INFO and SCRIPT_NAME when using nginx fastcgi. This caused django to fail in a bewildering way and took me quite a while to figure out.

03/03/10 13:56:06 changed by jacob

  • status changed from reopened to closed.
  • resolution set to invalid.

This isn't a bug, so I'm closing it. Feel free to open a new ticket with a documentation patch if you like.


Add/Change #8874 (problem with URLs on FastCGI after update to 1.0)




Change Properties
Action