flask + nginx =连接拒绝

时间:2013-03-13 20:21:33

标签: nginx

您好我正在尝试让我的本地计算机上运行nginx并运行。

我可以使用nginx服务器静态文件,但是我一直在使用uwsgi来解决连接问题。

我的nginx:

server {
    listen       80;
    server_name  localhost;

location /static {
    alias /path/to/my/static;
    autoindex  on;
}

location /media {
    alias  /media;
    autoindex  on;
}


location / {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/uwsgi.sock;
    uwsgi_param UWSGI_PYHOME /path/to/my/env;
    uwsgi_param UWSGI_CHDIR /path/to/my/app;
    uwsgi_param UWSGI_MODULE application;
    uwsgi_param UWSGI_CALLABLE app;
}

error_page   404              /404.html;

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

}

/etc/uwsgi/apps-available/uwsgi.ini:

[uwsgi]
plugins=python
vhost=true
socket=/tmp/uwsgi.sock

但如果我尝试localhost /,我会在nginx错误日志中找到它:

[error] 1021#0: *16 connect() to unix:/tmp/uwsgi.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/tmp/uwsgi.sock:", host: "localhost"

我尝试过更改权限,但我似乎无法解决这个问题。有人有什么建议吗?

任何帮助都将受到青睐。

1 个答案:

答案 0 :(得分:0)

一些想法:

  • 您确定uWSGI正在运行吗?
  • 您是否在应用程序中编辑该文件后重新加载/重新启动它?
  • 根据名称(apps-available)判断是否有另一个名为apps-enabled的目录,你需要在应用程序中为文件添加符号链接吗?
  • 是否存在uWSGI正在编写自己的错误消息的日志文件?

您可以将lsof与uWSGI pid(例如lsof -n -p 12345)一起使用,以查看它已打开的文件。您应该在/ tmp中看到套接字以及/ var / log

中的某个日志文件