2016-03-22 53 views
0

我試圖託管一個演示燒瓶應用程序,它在運行時返回「hi there」。使用此配置,我成功地使用http和https使用Uwsgi單獨託管應用程序。 當我試着使用HTTPS配置來訪問我的本地主機上的應用程序,我得到nginx與uwsgi和燒瓶顯示只有HTTPS連接的請求不好

502. Bad Gatewat 
nginx/1.4.6 (Ubuntu) 

在這裏不用我deployment.ini(uwsgi配置文件)

[uwsgi] 
shared-socket = 127.0.0.1:8443 
master = true 
processes = 5 
daemonize = /path/to/my/mylog.log 
wsgi-file=/path/to/my/demo.py 
callable=app 
https= =0,ca.crt,ca.key,HIGH 

我一直在使用Unix套接字也和了變化試過在其上的權限 共享插座= /路徑/到/ my.soc CHMOD插座= 664

使用第一配置我可以啓動該應用程序,但只與uwsgi,我想使它工作個粗糙的nginx。

在這裏不用我的nginx的配置

server { 
    listen 80; 
    listen [::]:80 default_server ipv6only=on; 

    root /usr/share/nginx/html; 
    index index.html index.htm; 
    error_log /path/to/nginx_err.log; 
    listen 443 ssl default_server; 

    server_name localhost; 

    ssl_certificate path/to/ca.crt; 
    ssl_certificate_key path/to/ca.key; 
    location/{ 
      uwsgi_pass 127.0.0.1:8443; 
      #uwsgi_pass unix:///path/to/my.soc; 
      include uwsgi_params; 
} 
} 

它可以正常使用了HTTPS,但我不知道發生了什麼,當我試圖給HTTPS配置

我的日誌文件/ var /日誌/ nginx的/ error.log

2016/03/22 15:58:07 [error] 12926#0: *2 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /user HTTP/1.1", upstream: "uwsgi://127.0.0.1:8443", host: "127.0.0.1" 

我已經花了大約8小時來解決這個問題,但不能。 任何幫助都非常感謝

回答

0

當它有nginx時,你不應該在uWSGI中配置與https有關的任何東西。

uWSGI中的https設置僅用於直接連接到uWSGI服務器。這將激活內置的http/https服務器,因此不再需要nginx。更重要的是,uWSGI不會在指定的端口上使用uwsgi協議進行通信,並且該協議在當前配置中由nginx預期。

更改uWSGI設置:

[uwsgi] 
socket = 127.0.0.1:8443 
master = true 
processes = 5 
daemonize = /path/to/my/mylog.log 
wsgi-file=/path/to/my/demo.py 
callable=app 

它會正常工作。不要擔心保證nginx或uWSGI之間的連接。如果它是本地連接(環回或安全的本地網絡),它不會是一個問題。

+0

完美地工作,謝謝一噸 –