Cherrypy 3.2.0 : starting engine to run both HTTP and HTTPS in th same instance

流过昼夜 提交于 2020-01-24 17:19:09

问题


Good morning,

I successfully start cherrypy 3.2.0 engine in HTTP OR HTTPS :

# ssl variable commes input parameters. Bellow cherrypy configuration is fully configured

if ssl:
    print('Setting up SSL')
    cherrypy.server.ssl_certificate = "conf/private/" + platform.node() + ".crt"
    cherrypy.server.ssl_private_key = "conf/private/" + platform.node() + ".key"


'''
----------------------------------
Start server instance
----------------------------------
'''
if hasattr(cherrypy.engine, 'block'):
    # 3.1 syntax
    cherrypy.engine.start()
    cherrypy.engine.block()
else:
    # 3.0 syntax
    cherrypy.server.quickstart(cherrypy.root, config=py_app_conf)
    cherrypy.engine.start() 

So, is it possible to configure cherrypy to start both in http AND https in the same cherrypy server ?

Thanks for ypur reply.


回答1:


You need to have two servers on different ports: Multiple servers/ports. Also there is a multi-server config feature that seems to be undocumented, see if it works for you, refer to _server_namespace_handler() function in _cpconfig.py.



来源:https://stackoverflow.com/questions/20581342/cherrypy-3-2-0-starting-engine-to-run-both-http-and-https-in-th-same-instance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!