Gunicorn HTTPs证书和密钥



要将ssl与django一起使用,我使用以下命令:

python3 manage.py runsslserver xx.8x.x3.x4:443 --certificate /etc/letsencrypt/live/callservps.online/fullchain.pem --key /etc/letsencrypt/live/callserv.com/privkey.pem

使用该证书和密钥运行gunicorn:

gunicorn --bind xx.8x.x3.x4:443:443 -certfile=/etc/letsencrypt/live/callserv.online/fullchain.pem -keyfile=/etc/letsencrypt/live/callserv.online/privkey.pem callservps.wsgi 

但是,它给了我错误。

无法连接到(xx.8x.x3.x4:43:443(

我认为问题在于证书和密钥的扩展名是.pem。但我不确定如何正确实现这一点,以使用https和那些证书和密钥运行gunicorn

使用以下openssl命令生成密钥对和自签名公钥证书。此示例生成一个椭圆曲线密钥对和一个自签名公钥证书,有效期为10年。

openssl req -x509 -nodes -days 3650 -newkey ec:<(openssl ecparam -name prime256v1) -keyout private_key.pem -out certificate.pem

这将提示您填写一些详细信息。使用项目文件夹中的密钥和证书文件,运行


gunicorn your-project.wsgi --keyfile private_key.pem --certfile certificate.pem

您的浏览器很可能会拒绝首次访问,这是一种安全风险(因为无法验证自签名证书,但接受风险并继续访问网站(。

最新更新