[cherrypy-users] Multiple Ports and SSL

71 views
Skip to first unread message

janglin

unread,
Oct 1, 2009, 2:43:33 PM10/1/09
to cherryp...@googlegroups.com

I have been trying to get a dual server application up and running where one
server serves HTTP and the other HTTPS using cherrypy 3.1.2. I have read
the other "Multiple Ports and SSL" thread here
http://www.nabble.com/Multiple-ports-and-SSL-td19736800.html#a20764816.

I did try the changes discussed in that thread to the files _cpserver.py,
_cpwsgi_server.py, and wsgiserver\__init_.py but it still did not work for
me. With those changes applied I get the following startup messages:
[01/Oct/2009:14:32:02] ENGINE Started monitor thread '_TimeoutMonitor'.
[01/Oct/2009:14:32:02] ENGINE Started monitor thread 'Autoreloader'.
[01/Oct/2009:14:32:03] ENGINE Serving on 0.0.0.0:8443
[01/Oct/2009:14:32:03] ENGINE Serving on 0.0.0.0:8080
[01/Oct/2009:14:32:03] ENGINE Bus STARTED

Yet when I navigate to http://localhost:8080 or https://localhost:8443 I get
101 errors (ERR_CONNECTION_RESET)

This is just with a small sample app:
import cherrypy
from cherrypy import _cpserver
import os.path

localDir = os.path.abspath(os.path.dirname(__file__))
CA = os.path.join(localDir, 'server.crt')
KEY = os.path.join(localDir, 'server.key')

def setup_app():
class Root(object):
@cherrypy.expose
def index(self):
return "Here is a page"

cherrypy.tree.mount(Root())


if __name__ == '__main__':

cherrypy.server2 = s2 = _cpserver.Server()
s2.socket_host = '0.0.0.0'
s2.socket_port = 8443
s2.ssl_certificate = CA
s2.ssl_private_key = KEY
s2.subscribe()

cherrypy.server.socket_host = '0.0.0.0'

setup_app()

cherrypy.engine.start()
cherrypy.engine.block()

As a matter of fact, I can't even connect a single server application when I
apply the changes discussed in the aforementioned thread ( I must have
missed something, it seemed to work for them).

Eventually I wish to have pages served via HTTP and web services (WSGI Apps)
served over HTTPS, but I can't get even a simple app working.

Can anyone provide suggestions?
--
View this message in context: http://www.nabble.com/Multiple-Ports-and-SSL-tp25704449p25704449.html
Sent from the cherrypy-users mailing list archive at Nabble.com.

janglin

unread,
Oct 2, 2009, 10:34:28 AM10/2/09
to cherryp...@googlegroups.com

Using cherrypy 3.2 beta0 (from trunk) with the same example code from before.
I now get a working ssl server but a non-working http server. When I
navigate to http://localhost:8080, I get a 400 error:

"The client sent a plain HTTP request, but this server only speaks HTTPS on
this port."

So internally cherrypy is using ssl on each server:port combination. If I
navigate to either https://localhost:8080 or https://localhost:8443 I get
the expected page over ssl. Am I using cherrypy in an incorrect manner or
is this a bug?

--
View this message in context: http://www.nabble.com/Multiple-Ports-and-SSL-tp25704449p25716501.html

Robert Brewer

unread,
Oct 3, 2009, 12:50:45 PM10/3/09
to cherryp...@googlegroups.com
janglin wrote:
> Using cherrypy 3.2 beta0 (from trunk) with the same example code
> from before. I now get a working ssl server but a non-working
> http server. When I navigate to http://localhost:8080, I get
> a 400 error:
>
> "The client sent a plain HTTP request, but this server only speaks
> HTTPS on this port."
>
> So internally cherrypy is using ssl on each server:port combination.
> If I navigate to either https://localhost:8080 or
https://localhost:8443
> I get the expected page over ssl. Am I using cherrypy in an incorrect
> manner or is this a bug?

A bug. Fixed in http://www.cherrypy.org/changeset/2536.

Incidentally, you should be able to use the new 'server.<name>.*'
attributes to do this more easily. See the 'scaffold' app in 3.2 for a
working example (just added):

[global]
# Uncomment this when you're done developing
#environment: "production"

server.socket_host: "0.0.0.0"
server.socket_port: 8088

# Uncomment the following lines to run on HTTPS at the same time
#server.2.socket_host: "0.0.0.0"
#server.2.socket_port: 8433
#server.2.ssl_certificate: '../test/test.pem'
#server.2.ssl_private_key: '../test/test.pem'

tree.myapp: cherrypy.Application(scaffold.root, "/", "example.conf")


Robert Brewer
fuma...@aminus.org

janglin

unread,
Oct 5, 2009, 9:07:27 AM10/5/09
to cherryp...@googlegroups.com

Thanks, everything works now as expected with latest trunk, 2548 is the one I
got.
--
View this message in context: http://www.nabble.com/Multiple-Ports-and-SSL-tp25704449p25750503.html
Reply all
Reply to author
Forward
0 new messages