Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyramid pserve server as https

Is it possible to run Pyramid's pserve such that it starts an https server (for example https://0.0.0.0:6543)?

I would like to gear up my application for https locally if possible.

like image 503
Roman Avatar asked Nov 06 '14 14:11

Roman


2 Answers

pserve uses waitress as it's server by default, however you can replace the server used by updating your .ini configuration file:

[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 5900

For example:

[server:main]
use = egg:gunicorn
host = 0.0.0.0
port = 5900
workers = 1
worker_class = gevent

gunicorn has support for SSL out of the box from looking at the documentation, and you could add the following to enable SSL:

certfile=~/ssl/server.crt
keyfile=~/ssl/server.key
ssl_version=3

This should allow you to run pserve and have an SSL enabled server. In most cases if you are deploying your project you would want to use nginx to proxy requests to your backend server, and have nginx do the SSL termination.

like image 200
X-Istence Avatar answered Apr 06 '23 02:04

X-Istence


I don't think you can do it with only pserve. If you really need HTTPS for developing, I would suggest you do as in production. For example, use nginx as a reverse proxy that would handle HTTPS and pass HTTP to your application.

like image 29
Antoine Leclair Avatar answered Apr 06 '23 01:04

Antoine Leclair