URL issue when using lighttpd, django and fastcgi

I just installed fastcgi with lighty for django, but I get the path to the fcgi file when it processes the url, for example. 404 at http://myserver.myhost.com/myproject.fcgi . It should be sent to / instead of / myproject.fcgi.

Lighty conf:

$HTTP["host"] =~ "myproject\.myhost\.com" {
        fastcgi.server = (
         ".fcgi" => (
           "localhost" => (
             "bin-path" => "/var/www/myproject/myproject.fcgi",
             "socket" => "/tmp/myproject.sock",
             "check-local" => "disable",
             "min-procs" => 2,
             "max-procs" => 4,
          )
        ),
)

        alias.url = (
            "/media" => "/usr/local/lib/python1.6/dist-packages/Django-1.2.1-py2.6.egg/django/contrib/admin/media/",
        )

        url.rewrite-once = (
        "^(/media.*)$" => "$1",
        "^/favicon\.ico$" => "/media/favicon.ico",
        "^(/.*)$" => "/myproject.fcgi$1",
    )
}

myproject.fcgi:

#!/usr/bin/python2.6
import sys, os

# Add a custom Python path.
sys.path.insert(0, "..")

# Switch to the directory of your project. (Optional.)
os.chdir("/var/www/myproject")

os.environ['DJANGO_SETTINGS_MODULE'] = "settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(["method=threaded", "daemonize=false"])
+3
source share
1 answer

I answer my question again. Put it in settings.py

FORCE_SCRIPT_NAME = ""
+9
source

Source: https://habr.com/ru/post/1758644/


All Articles