2017-08-16 58 views
0

我試圖在運行在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"

+0

你提到「以下本教程供參考」,但沒有鏈接。什麼是教程? – David

回答

0

日誌說沒有這樣的文件或目錄是因爲你不設置了插座的Nginx config,嘗試添加它,像這樣:

location/{ 
      proxy_pass http://unix:/tmp/pybossa.sock 
+0

套接字在uwsgi配置文件中設置。我編輯了這個帖子來補充。 部分問題是uwsgi未運行,因爲它沒有正確安裝,這篇文章https://stackoverflow.com/questions/13965555/after-pip-installing-uwsgi-theres-no-etc- uwsgi-directory-how-can-i-use-apps解釋瞭如何讓它運行。現在uwsgi正在運行,它發出500內部服務器錯誤。 – bobthecoder

+0

當我將套接字添加到nginx配置nginx無法重新啓動 – bobthecoder

0

檢查uwsgi錯誤日誌。它應該說,爲什麼它失敗或返回500.另外,再次檢查套接字是否創建了正確的權限,所以nginx可以連接到它。