我試圖在運行在Google雲上的NGINX服務器上安裝Pybossa(使用Flask構建的webapp)(參考本教程,以供參考)。我認爲我使用的虛擬主機文件有問題,因爲一旦啓用它,服務器將返回502壞的網關。該谷歌Compute Engine的VM實例運行Debian 8.谷歌雲計算引擎上的Flask + NGINX + UWSGI給502錯誤的網關
完整的hosts文件是在這裏:
server {
listen 80;
server_name _;
large_client_header_buffers 4 32k;
real_ip_header X-Forwarded-For;
# change that to your pybossa directory
root /home/pybossa/pybossa;
client_max_body_size 5M;
if (-f /home/pybossa/pybossa/503.html) {
return 503;
}
error_page 503 @maintenance;
location/{ try_files $uri @pybossa; }
location @pybossa {
include uwsgi_params;
uwsgi_pass unix:/tmp/pybossa.sock;
}
location /static {
# change that to your pybossa static directory
alias /home/pybossa/pybossa/pybossa/themes/default/static;
autoindex on;
expires max;
}
location ~ /api/app {
rewrite ^/api/app /api/project$1 permanent;
}
location ~ /app {
rewrite ^/app(.*) /project$1 permanent;
}
error_page 503 @maintenance;
location @maintenance {
if ($uri !~ ^/static/) {
rewrite ^(.*)$ /503.html break;
}
}
}
而且uwsgi配置文件:
[uwsgi]
socket = /tmp/pybossa.sock
chmod-socket = 666
chdir = /home/pybossa/pybossa
pythonpath = ..
virtualenv = /home/pybossa/pybossa/env
module = run:app
cpu-affinity = 1
processes = 2
threads = 2
stats = /tmp/pybossa-stats.sock
buffer-size = 65535
我最初設置了我自己的NGINX服務器,但沒有工作。現在我正在谷歌雲部署的NGINX服務器上運行它,它工作正常,直到我在/ etc/nginx/sites-enabled /中啓用了虛擬主機文件。
的/var/log/nginx/error.log
包含以下內容:
2017/08/16 21:53:30 [alert] 439#0: *21 open socket #13 left in connection 4
2017/08/16 21:53:30 [alert] 439#0: *21 open socket #13 left in connection 4
2017/08/16 21:53:30 [alert] 439#0: aborting
2017/08/16 21:53:32 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:13 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:14 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:14 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:35 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:36 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:37 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 21:54:51 [crit] 16744#0: *1 connect() to unix:/tmp/pybossa.sock failed (2: No such file or directory) while connecting to upstream, client: 68.107.113.211, server: _, reques
t: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
我新的Web應用程序開發和以前沒有使用瓶或NGINX。感謝任何幫助,我可以得到。
UPDATE:固定在那裏uwsgi未運行的問題之後,現在的錯誤日誌說
2017/08/16 23:53:27 [alert] 23944#0: *26 open socket #7 left in connection 3
2017/08/16 23:53:27 [alert] 23944#0: aborting
2017/08/16 23:53:30 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 23:53:30 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 23:53:31 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 23:53:31 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 23:53:31 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 23:54:29 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
2017/08/16 23:54:30 [error] 24536#0: *1 connect() to unix:/tmp/pybossa.sock failed (111: Connection refused) while connecting to upstream, client: 68.107.113.211, server:
_, request: "GET/HTTP/1.1", upstream: "uwsgi://unix:/tmp/pybossa.sock:", host: "35.184.197.200"
你提到「以下本教程供參考」,但沒有鏈接。什麼是教程? – David