2016-12-16 164 views
1

我需要讓uWSGI只允許通過https進行連接。 我只能使用uWSGI而不能使用NGINX等額外應用程序。uWSGI配置使用HTTPS

現在,我會滿足,如果我可以使https部分作品。

我試過了uwsgi站點的代碼(稍作修改):http://uwsgi-docs.readthedocs.io/en/latest/HTTPS.html。但它不起作用。

[uwsgi] 
master = true 

socket = 127.0.0.1:9000 
shared-socket = 0.0.0.0:443 
https = =0,foo.crt,foo.key,HIGH 

module=project.wsgi:application 

enable-threads = true 
vacuum = true 
die-on-term = true 

從瀏覽器中,我得到了網站無法達到 我有相同的文件夾上面和下面的代碼配置文件證書「foo.crt」和「foo.key」。證書是自簽名證書。

我也嘗試下面的代碼,但只適用HTTP和HTTPS不是:

[uwsgi] 
;master process with 5 workers. 
master = true 
processes = 5 

http = :80 
https = :443,foo.crt,foo.key 

buffer-size = 32768 

module=project.wsgi:application 

enable-threads = true 
vacuum = true 
die-on-term = true 

如果你知道如何使這個HTTPS作品那會真棒。 甚至更​​好,如果它還包括http重定向到https。

在此先感謝。

+0

第一眼事情是不對您的HTTPS指令。它在開始時不具有= 0或= 1。看到這個答案http://stackoverflow.com/a/37511426/334346。注意那裏的http-to-https指令。 – Oleg

回答

1

得到這個工作爲https。

像奧列格說,我懷念那個= 0

[uwsgi] 
;master process with 5 workers. 
master = true 
processes = 5 

shared-socket = 0.0.0.0:443 
https = =0,foo.crt,foo.key,HIGH 

module=project.wsgi:application 

enable-threads = true 
vacuum = true 
die-on-term = true