Alexander Yau Alexander Yau - 10 months ago 69
Python Question

ipython: access notebook server remotely via a web browser

I want to access notebook server remotely via a web browser, the following shows how did I setup my notebook server:

1.generate config file

$ jupyter-notebook --generate-config
$ cd ~/.jupyter

2.Use the following command to create the SSL certificate(Linux and Windows).

req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

3.edit the profile's configuration file, which is the
the password has been generated..

c = get_config()

# You must give the path to the certificate file.
c.NotebookApp.certfile = u'/home/azureuser/.jupyter/mycert.pem'

# Create your own password as indicated above
c.NotebookApp.password = u'sha1:b86e933199ad:a02e9592e5 etc... '

# Network and browser details. We use a fixed port (9999) so it matches
# our Azure setup, where we've allowed :wqtraffic on that port
c.NotebookApp.ip = '*'
c.NotebookApp.port = 9999
c.NotebookApp.open_browser = False

$ jupyter-notebook

You should now be able to access your Jupyter Notebook at the address https://[PUBLIC-IP-ADDRESS]:9999.

Start notebook:

$ ~ jupyter-notebook
[I 16:46:58.627 NotebookApp] Serving notebooks from local directory: /home/user
[I 16:46:58.627 NotebookApp] 0 active kernels
[I 16:46:58.627 NotebookApp] The Jupyter Notebook is running at: https://SERVER_IP:9999/
[I 16:46:58.627 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

But, when I open my browser(at my home, the notebook server is in my lab) at https://MY_SERVER_IP:9999, the page can not be open. And Chrome-browser returns:


What should I do?


The corresponding port 9999 is block on the server, and the server is Centos7 and iptables is not available to open ports, so use firewall-cmd to active the port:

$ firewall-cmd --zone=public --add-port=9999/tcp --permanent
$ firewall-cmd --reload

If firewallD is not running, just start the service.