网关400错误请求Nginx

2024-05-01 09:09:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我是第一次设置这个堆栈(nginx、uwsgi、django应用程序)

目前我对我现在做的事情很模糊,希望有人能给我一些指导。 这是我下面的文档。 https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html

我设法做到的是,我可以通过virtualenv中的uwsgi访问我的web应用程序

uwsgi --http :8000 --module folio.wsgi:application   

现在阻止我的是在我启动nginx之后,当我访问192.168.92.148:8001时,我收到了400个错误请求。下面是我的档案

ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.92.148  netmask 255.255.255.0  broadcast 192.168.92.255
        inet6 fe80::b9d9:2ea2:a116:9c31  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:75:cf:c6  txqueuelen 1000  (Ethernet)
        RX packets 391924  bytes 349216106 (349.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 218500  bytes 65221010 (65.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

folio_nginx.conf文件

upstream django {
    server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}

server {
    listen      8001;
    server_name 192.168.92.148;
    charset     utf-8;

    client_max_body_size 75M;   

    location /static {
        alias /home/yao1122/Project/folio/folio/static; 
    }

    location / {
        uwsgi_pass  django;
        include     /home/yao1122/Project/folio/uwsgi_params;
    }
}

uwsgi_参数文件

uwsgi_param  QUERY_STRING       $query_string;
uwsgi_param  REQUEST_METHOD     $request_method;
uwsgi_param  CONTENT_TYPE       $content_type;
uwsgi_param  CONTENT_LENGTH     $content_length;

uwsgi_param  REQUEST_URI        $request_uri;
uwsgi_param  PATH_INFO          $document_uri;
uwsgi_param  DOCUMENT_ROOT      $document_root;
uwsgi_param  SERVER_PROTOCOL    $server_protocol;
uwsgi_param  REQUEST_SCHEME     $scheme;
uwsgi_param  HTTPS              $https if_not_empty;

uwsgi_param  REMOTE_ADDR        $remote_addr;
uwsgi_param  REMOTE_PORT        $remote_port;
uwsgi_param  SERVER_PORT        $server_port;
uwsgi_param  SERVER_NAME        $server_name;

谁能解释一下我做错了哪一部分? 或者是否有用于调试的日志文件

谢谢大家阅读这篇文章


Tags: 文件djangohttpsweb应用程序serverparamport