Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uWSGI configuration to use HTTPS

I need to have uWSGI to only allow connection through https. I can only use uWSGI and not with extra application such as NGINX.

For now, I would be content if I can make the https part works.

I tried the code (with slight modification) from uwsgi site: http://uwsgi-docs.readthedocs.io/en/latest/HTTPS.html. But it does not work.

[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

From the browser, I got the site cannot be reach I have the certificate "foo.crt" and "foo.key" on the same folder as the configuration file for the code above and below. The certificate is a self sign certificate.

I also tried the following code, but only works the http and not 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

If you know how to make this HTTPS works that would awesome. Even better, if it also includes http redirect to https.

Thanks in advance.

like image 345
Lukas Avatar asked Sep 12 '25 06:09

Lukas


1 Answers

Got this to work for https.

Like Oleg said, I miss that =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
like image 164
Lukas Avatar answered Sep 13 '25 18:09

Lukas