0

开始:

我正在使用 fastcgi/nginx 和 django 运行我的网站。我已经成功启动服务器,没有错误。我运行了 manage.py runserver 并访问了该网站,它有一个在 manage.py 下工作的菜单,但是当我使用 manage.py runfcgi 启动它时:

python manage.py runfcgi method=prefork maxchildren=30 host=127.0.0.1 port=4300 pidfile=pid workdir="$PWD" daemonize=false outlog="$LOGFILE" errlog="$LOGFILE"

该应用程序只为我提供网站的第一页。

例如:

   If I go to mywebsite.com this being the home page I get the right 
   template home.html.
   If I visit mywebsite.com/get-started ,the server tries to render the same home.html.

使用 manage.py runserver 有效,但使用 runfcgi 则无效。

PS:该网站使用了一些cookies并且它有一个自定义渲染功能,它是来自github的indextank服务,店面应用:https ://github.com/linkedin/indextank-service 你可以通过manage.py运行它。

当我尝试导航顶部菜单时,通过 runfcgi 运行它并不会更改页面,它会发出请求,但它会使用相同的模板,即“home.html”

任何想法都非常感谢。

另外:服务器 fastcgi 配置非常标准:

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

#fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

和应用程序 fastcgi 配置:

server {
        listen 80;
    server_name  search.spid.me www.search.spid.me;
        client_max_body_size 1m;

        location / {
            #fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        fastcgi_pass  127.0.0.1:4300;
            include     fastcgi_params;
        #fastcgi_param  QUERY_STRING       $query_string;
            #fastcgi_param  REQUEST_METHOD     $request_method;
            #fastcgi_param  CONTENT_TYPE       $content_type;
            #fastcgi_param  CONTENT_LENGTH     $content_length;
        #fastcgi_param  PATH_INFO          $fastcgi_script_name;
        #fastcgi_pass 127.0.0.1:4300;
            #fastcgi_param PATH_INFO $fastcgi_script_name;
            #fastcgi_param REQUEST_METHOD $request_method;
            #fastcgi_param QUERY_STRING $query_string;
            #fastcgi_param SERVER_NAME $server_name;
            #fastcgi_param SERVER_PORT $server_port;
            #fastcgi_param SERVER_PROTOCOL $server_protocol;
            #fastcgi_param CONTENT_TYPE $content_type;
            #fastcgi_param CONTENT_LENGTH $content_length;
            #fastcgi_pass_header Authorization;
            #fastcgi_intercept_errors off;
        }

        location /_static {
            expires 24h;
            autoindex on;
            alias /home/indextank/storefront/static/;
        }

        location /nginx_status {
            stub_status on;
            access_log off;
            deny all;
            allow 127.0.0.1;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

 server {
    server_name  spid.search.me www.spid.search.me;
        listen 443;
        ssl on;
    #ssl_certificate /etc/nginx/conf.d/server.crt;
        #ssl_certificate_key /etc/nginx/conf.d/server.key;
        server_name  search.spid.me www.search.spid.me;
        client_max_body_size 1m;

        location / {
            fastcgi_pass  127.0.0.1:4300;
            include     fastcgi_params;
            fastcgi_param HTTPS on;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

我做了更多调试,结果发现请求的路径和 path_info 没有设置...

4

1 回答 1

0

发现了问题。我在 fastcgi 参数文件中丢失了一些 fastcgi_params。我添加了这些,它似乎已经解决了这个问题。

于 2012-06-22T00:17:05.277 回答