How to forward http to https in cherrypy native web server

144 views Asked by At

I've a Cherrypy website that is running well on https, I can run the same server on http port without forward like this:

from cherrypy._cpserver import Server
server2 = Server()
server2.socket_host = "123.123.123.123"
server2.socket_port = 80
server2.subscribe()

I can run another Cherrypy instance on http port and forward it https by having rise cherrypy.HTTPRedirect in the class:


class HelloWorld(object):
    @cherrypy.expose
    def index(self):
        raise cherrypy.HTTPRedirect("https://example.com", status=301)

Is there a way to forward http to https without running another server or using 3rd party service?

0

There are 0 answers