Running Gunicorn on both http and https

When I start my Gunicorn service, I currently use this command to start it: gunicorn --certfile = / Projects / thebodyofchrist.us.crt --keyfile = / Projects / thebodyofchrist.us.key bodyofchrist.wsgi -b 0.0. 0.0: 443 -b 0.0.0.0:80 -w 10

To bind the gun to http and https - or configure apache2 to listen on http and redirect requests to https with existing parameters. I have hundreds of links to http://domain.com/sample/request and it needs to automatically go to https://domain.com/sample/request

gunicorn is taking django.

Thanks for any help!

+5
source share
2 answers

Gunicorn is a very solid project, I hope that someday he will build it using several port bindings and a command line to indicate the priority of SSL.

When you finally start production, you will want to use the excellent Apache or Nginx load balancing.

But nothing prevents you (during development) from starting some workers associated with port 80, and some workers are tied to port 443 with a set of keys and certificates. Then you could write a login link as an β€œabsolute” URL, for example. href = "https: // yoursite / login" after logging in, they will use https URL.

 #!/bin/sh # put 8 workers as Daemon listening for HTTPS on 443 gunicorn -D -w 8 --certfile=/Projects/thebodyofchrist.us.crt --keyfile=/Projects/thebodyofchrist.us.key bodyofchrist.wsgi -b 0.0.0.0:443 # put 2 workers as Daemon listening for HTTP on port 80 gunicorn -D -w 2 bodyofchrist.wsgi -b 0.0.0.0:80 
+1
source

Such support can be added inside the gun. As a moment, this is not possible.

https://github.com/benoitc/gunicorn/issues/1466

0
source

Source: https://habr.com/ru/post/1243666/


All Articles