Opened 16 years ago

Closed 15 years ago

Last modified 13 years ago

#8874 closed Uncategorized (invalid)

problem with URLs on FastCGI after update to 1.0

Reported by: kyprizel Owned by: kyprizel
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: qingfeng@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (4)

wsgi.patch (983 bytes ) - added by kyprizel 16 years ago.
simple wsgi patch to solve problem
wsgi_r11339.diff (1.1 KB ) - added by QingFeng 15 years ago.
nginx.conf (1.1 KB ) - added by QingFeng 15 years ago.
nginx.conf
sina.conf (628 bytes ) - added by QingFeng 15 years ago.
Django Application conf

Download all attachments as: .zip

Change History (22)

comment:1 by kyprizel, 16 years ago

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)

comment:2 by kyprizel, 16 years ago

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?

comment:3 by kyprizel, 16 years ago

Owner: changed from nobody to kyprizel
Status: newassigned

by kyprizel, 16 years ago

Attachment: wsgi.patch added

simple wsgi patch to solve problem

comment:4 by kyprizel, 16 years ago

Has patch: set

comment:5 by kyprizel, 16 years ago

Keywords: error removed
Triage Stage: UnreviewedDesign decision needed

comment:6 by QingFeng, 16 years ago

Cc: qingfeng@… added
Has patch: unset

Django+nginx+prefork is problem too

comment:7 by QingFeng, 16 years ago

Has patch: set

comment:8 by Malcolm Tredinnick, 16 years ago

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.

comment:9 by Malcolm Tredinnick, 16 years ago

Triage Stage: Design decision neededAccepted

(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.)

by QingFeng, 15 years ago

Attachment: wsgi_r11339.diff added

comment:10 by QingFeng, 15 years ago

milestone: 1.2
Version: 1.0SVN

comment:11 by QingFeng, 15 years ago

Resolution: duplicate
Status: assignedclosed

fixed #8490

in reply to:  11 comment:12 by Karen Tracey, 15 years ago

Resolution: duplicate
Status: closedreopened

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.

by QingFeng, 15 years ago

Attachment: nginx.conf added

nginx.conf

by QingFeng, 15 years ago

Attachment: sina.conf added

Django Application conf

comment:13 by QingFeng, 15 years ago

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

comment:14 by Exe, 15 years ago

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;
    }

comment:15 by btmorex, 15 years ago

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.

comment:16 by Jacob, 15 years ago

Resolution: invalid
Status: reopenedclosed

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

comment:17 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

comment:18 by Aymeric Augustin, 13 years ago

Easy pickings: unset
Severity: Normal
Type: Uncategorized
UI/UX: unset

See #17550 for an annoying consequence of this fix.

Note: See TracTickets for help on using tickets.
Back to Top