Opened 7 years ago

Closed 5 years ago

Last modified 4 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: master
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 7 years ago.
simple wsgi patch to solve problem
wsgi_r11339.diff (1.1 KB) - added by qingfeng 6 years ago.
nginx.conf (1.1 KB) - added by qingfeng 6 years ago.
nginx.conf
sina.conf (628 bytes) - added by qingfeng 6 years ago.
Django Application conf

Download all attachments as: .zip

Change History (22)

comment:1 Changed 7 years ago by kyprizel

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 7 years ago 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?

comment:3 Changed 7 years ago by kyprizel

  • Owner changed from nobody to kyprizel
  • Status changed from new to assigned

Changed 7 years ago by kyprizel

simple wsgi patch to solve problem

comment:4 Changed 7 years ago by kyprizel

  • Has patch set

comment:5 Changed 7 years ago by kyprizel

  • Keywords error removed
  • Triage Stage changed from Unreviewed to Design decision needed

comment:6 Changed 7 years ago by qingfeng

  • Cc qingfeng@… added
  • Has patch unset

Django+nginx+prefork is problem too

comment:7 Changed 7 years ago by qingfeng

  • Has patch set

comment:8 Changed 7 years ago 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.

comment:9 Changed 7 years ago by mtredinnick

  • Triage 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.)

Changed 6 years ago by qingfeng

comment:10 Changed 6 years ago by qingfeng

  • milestone set to 1.2
  • Version changed from 1.0 to SVN

comment:11 follow-up: Changed 6 years ago by qingfeng

  • Resolution set to duplicate
  • Status changed from assigned to closed

fixed #8490

comment:12 in reply to: ↑ 11 Changed 6 years ago by kmtracey

  • Resolution duplicate deleted
  • Status changed from closed to reopened

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.

Changed 6 years ago by qingfeng

nginx.conf

Changed 6 years ago by qingfeng

Django Application conf

comment:13 Changed 6 years ago 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

comment:14 Changed 6 years ago 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;
    }

comment:15 Changed 5 years ago 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.

comment:16 Changed 5 years ago by jacob

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

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 Changed 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

comment:18 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

See #17550 for an annoying consequence of this fix.

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