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]
socket = 127.0.0.1:8003
touch-reload=/myblog/reload
processes = 2
threads = 4
vacuum = true
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 {
}
}
#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 端口连不上,端口已经开放,防火墙已经关闭,求解,感激不尽!
1
peter999 2016-05-13 19:20:55 +08:00
selinux
|
2
peter999 2016-05-13 19:22:24 +08:00
nginx 监听的 ip 是不是写成本地了,保险的话写成 0.0.0.0
|
3
pc10201 2016-05-13 19:36:35 +08:00
先直接用 uwsgi 跑 django 试一下,没有问题再与 nginx 一起开
|
4
crazycabbage OP @peter999 写的是 0.0.0.0
|
5
crazycabbage OP @pc10201 uwsgi 跑是能成功的,端口是 8003 , nginx 端口是 8000
|
6
peter999 2016-05-13 19:43:36 +08:00
配置个静态目录看能访问到吗,还有目录和文件权限问题
|
7
peter999 2016-05-13 19:44:18 +08:00
如果你有路由器又是通过外网 ip 访问,还要检查下路由器上端口是不是被别的机器占用了
|
8
crazycabbage OP @peter999 没有用路由器,端口换了也没用,根据错误日志是 upstream timed out (110: Connection timed out) while reading response header from upstream ,超时,谜一样
|
9
zwzmzd 2016-05-14 01:21:33 +08:00 via Android
如果直接用 uwsgi 作前端,会有什么问题么?长期裸跑 uwsgi 的路过
|
10
wizardoz 2016-05-14 15:47:03 +08:00
你有没有搞错? 8003 端口正常访问?
nginx 访问 uwsgi 用的是 wsgi 协议,浏览器访问 uwsgi 用的是 http 哦。 |
11
wizardoz 2016-05-14 15:53:59 +08:00
把配置文件中的
socket = 127.0.0.1:8003 改成 uwsgi-socket = 127.0.0.1:8003 试试 或者手动起 uwsgi ,再用 nginx 反代过来试试。 |
12
wizardoz 2016-05-14 15:55:27 +08:00
然后再把
uwsgi-socket = 127.0.0.1:8003 改成 uwsgi-socket = 0.0.0.0:8003 试试 |
13
crazycabbage OP @wizardoz 谢谢了,已经解决了,估计是 uwsgi_param UWSGI_SCRIPT myblog.wsgi;uwsgi_param UWSGI_CHDIR /myblog;这个问题,我是用 supervisor 来管理的
|