>  Q&A  >  본문

python - centos7+django+uwsgi+nginx访问报错

报错如下:
2016/05/13 19:02:40 [error] 11057#0: *162 upstream prematurely closed connection while reading 
response header from upstream, client: xxx.xxx.xxx.xxx, server: xxx.xxx.xxx.xxx, request: "GET 
/poweredby.png HTTP/1.1", upstream: "uwsgi://127.0.0.1:8003", host: "xxx.xxx.xxx.xxx:8000", 
referrer: "http://xxx.xxx.xxx.xxx:8000/"
uwsgi 配置如下:
[uwsgi]
socket = 127.0.0.1:8003
touch-reload=/myblog/reload

processes = 2
threads = 4
vacuum = true
nginx 配置如下:
 server {
        listen       8000;
        server_name  xxx.xxx.xxx.xxx;
        root         /usr/share/nginx/html;
        access_log /logs/access.log;
        error_log /logs/error.log;

        charset     utf-8;

        # Load configuration files for the default server block.

        location / {
            include  /etc/nginx/uwsgi_params;
            uwsgi_pass  127.0.0.1:8003;
            client_max_body_size 35m;
            uwsgi_param UWSGI_SCRIPT myblog.wsgi;
            uwsgi_param UWSGI_CHDIR /myblog;
        }
        location /media  {
            alias /path/to/project/media;
        }

        location /static {
            alias /path/to/project/static;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
views.py 文件内容
#coding:utf-8
from django.shortcuts import render
from django.http import HttpResponse

# Create your views here.
def index(request):
    return HttpResponse(u"Hello World!!")

搞了一天了,死活连不上, uwsgi8003 端口正常访问, nginx 代理 8000 端口连不上,端口已经开放,防火墙已经关闭,求解,感激不尽!

PHP中文网PHP中文网2741일 전214

모든 응답(1)나는 대답할 것이다

  • 阿神

    阿神2017-04-17 17:46:17

    으아악

    그리고 uWSGI 구성 파일이 약간 이상합니다. 튜토리얼을 어디서 읽었는지 모르겠습니다. 어쨌든 uWSGI + Nginx + Django 전체 구성 과정은 [uWSGI 및 nginx를 사용하여 Django 및 웹 서버 설정]을 참조하세요. uWSGI 공식 문서가 있으면 좋을 것 같습니다.

    커뮤니케이션 프로세스:
    客户端访问8000 ——> Nginx -8003-> uWSGI ——> Django 공식 문서의 단계를 따르면 단계별로 구성 및 확인되며 어떤 링크가 잘못되었는지 명확해집니다.

    회신하다
    0
  • 취소회신하다