Connect to IPython via HTTPS, got SSL error

This question is migrated from here.

I have a server running Ubuntu 12.04. I have installed IPython on it. Now, I would like to access IPython via HTTPS.

I have done the following steps:

  • Creating an SSL certificate with openssl: openssl req -x509 -nodes -newkey rsa:1024 -keyout ipython_cert.pem -out ipython_cert.pem

  • Create a password hash, in IPython:

    from IPython.lib import passwd

    passwd()

  • Creating a Notebook profile: ipython profile create nbserver

  • Edit the config file for the nbserver profile: nano /.ipython/profile_nbserver/ipython_notebook_config.py

    c = get_config()
    c.IPKernalApp.pylab = 'inline'
    c.NotebookApp.certfile = u'/home/user/ipython_cert.pem'
    c.NotebookApp.ip = '*'
    c.NotebookApp.open_browser = False
    c.NotebookApp.password = u'XXX'
    c.NotebookApp.port = 4096
    c.NotebookManager.notebook_dir = u'/home/user/pynb'
    

Next, I start IPython notebook like this: ipython notebook --profile nbserver. Now, in my browser on my laptop, I enter the IP address of my server, followed by port number 4096. IPython throws this error:

SSL Error on 6 ('ip address', 54169): [Errno 1] _ssl.c:504: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request

Why is this and how can I fix this?


By typing an IP or a domain name into the address bar of the browser, the browser assumes HTTP by default. This is what happened to you here, the Browser expects HTTP traffic, but the server serves HTTPS on this port. Thus the Browser complained, that the answer of the server has a fundamental deviation from the expected form.

Thus the the solution is to prefix your IP/internal domain name by https:// the browsers address bar.