# Running slicer-notebook Docker behind HTTPS reverse proxy?

**URL:** <https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066>\
**Category:** Support\
**Created:** [December 14, 2020, 11:59pm UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066 "2020-12-14T23:59:56Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nadya\_Shusharina](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nadya_shusharina/32/9186_2.png) [@Nadya\_Shusharina](https://discourse.slicer.org/u/Nadya_Shusharina)\
**Post date:** [December 14, 2020, 11:59pm UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/1 "2020-12-14T23:59:56Z")

</div>

Operating system: CentOS 7  
Slicer version: 4.11 ( [https://github.com/Slicer/SlicerDocker](https://github.com/Slicer/SlicerDocker) - lassoan/slicer-notebook:2020-05-15-89b6bb5 )  
I would like to run the container behind an Apache 2.4 as reverse proxy, so I could access the Slicer Jupyter notebook and in-browser Slicer GUI externally, at e.g. [https://example.com/slicer](https://example.com/slicer) while all other URLs from [example.com](http://example.com) are served by Apache directly.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 17, 2020, 6:33am UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/2 "2020-12-17T06:33:02Z")

</div>

> I have tried the slicer-notebook docker container, and it is a really cool way of integrating both the Slicer GUI and its Jupyter notebook in the same web browser. It works great on my local computer, and I am trying to use on a web server as a prototype for interactive visualizations. To do that, I am running the docker container on the same machine as the web server, and I need to set up reverse proxy so that the container output at port 8888 is served externally at port 443 (https). My server is running Apache 2.4, fully configured, running a Joomla based website. Thus, I need to reverse-proxy the container to [https://example.com/myslicer](https://example.com/myslicer)
> 
> I am following [https://stackoverflow.com/questions/23890386/how-to-run-ipython-behind-an-apache-proxy](https://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F23890386%2Fhow-to-run-ipython-behind-an-apache-proxy&data=04%7C01%7Classo%40queensu.ca%7Cd966ce4dd78d41b7ea0708d8a2472612%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C637437773763351373%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000&sdata=SKYsXw7lSGYoqoGMLX%2BTdZNba%2FfCM2fOboRLEr8A6%2Bs%3D&reserved=0)  
> and it appears that for reverse proxy to work, the container would have to expose the notebook not at 127.0.0.1:8888/ but 127.0.0.1:8888/myslicer
> 
> I was wondering if you could help me reconfigure the container to make this change?

Sorry for the slow answer, we are all very busy at the Slicer Project Week. I would love to see this working.

Instead of trying to set all this up manually, have you considered to use [JupyterHub](https://jupyterhub.readthedocs.io/en/stable/reference/technical-overview.html)? This is what binder uses and it supports multiple users, providing a dedicated server to each of them.

If you want to expose a single Jupyter server then it may be a matter of configuring the apache server to direct the [example.com/slicer](http://example.com/slicer) traffic to the Jupyter server and set the Jupyter server base url in the Jupyter configuration file (as it is explained [here](https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#running-the-notebook-with-a-customized-url-prefix)). To set Jupyter configuration file in the image, you can upload it to the [dockerfile folder](https://github.com/Slicer/SlicerDocker/tree/master/slicer-notebook) and add a copy command into the [Dockerfile](https://github.com/Slicer/SlicerDocker/blob/master/slicer-notebook/Dockerfile) to put it to a place where Jupyter will find it (see info [here](https://jupyter-notebook.readthedocs.io/en/stable/config.html) on how to generate a default configuration and where should it be).

---

<div class="post-metadata">

**Author:** ![Nadya\_Shusharina](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nadya_shusharina/32/9186_2.png) [@Nadya\_Shusharina](https://discourse.slicer.org/u/Nadya_Shusharina)\
**Post date:** [December 18, 2020, 3:40am UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/3 "2020-12-18T03:40:27Z")

</div>

Thank you - I am building it for a single user. I have created jupyter\_notebook\_config.py, added it to the Dockerfile and I rebuilt the container. The reverse proxy works as I can start a Python3 Jupyter notebook at [https://example.com/myslicer](https://example.com/myslicer)  
Here is my reverse proxy configuration for Apache 2.4 just in case:

```auto
<Location /myslicer>
ProxyPass http://localhost:8888/myslicer
ProxyPassReverse http://localhost:8888/myslicer
ProxyPassReverseCookieDomain localhost example.com
RequestHeader set Origin "http://localhost:8888"
</Location>
<Location "/myslicer/api/kernels">
        ProxyPass ws://localhost:8888/myslicer/api/kernels
        ProxyPassReverse ws://localhost:8888/myslicer/api/kernels
</Location>

```

However, the Slicer 4.11 notebook would not start:

```auto
error: [/home/sliceruser/Slicer-4.11.0-2020-05-14-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 03:20:11.378 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports

```

Further, when building the container, the following errors occur:

```auto
Step 35/46 : RUN ./install.sh ${HOME}/$SLICER_ARCHIVE/Slicer
 ---> Running in ac94ada5b72e
_XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.
QIODevice::read (QFile, "/home/sliceruser/.config/NA-MIC/Extensions-29057/SlicerJupyter/share/Slicer-4.11/qt-loadable-modules/JupyterKernel/Slicer-4.11/kernel-template.json"): device not open
virtual bool qSlicerJupyterKernelModule::installSlicerKernel(QString) : launching "/usr/local/bin//jupyter-kernelspec" "install /home/sliceruser/.config/NA-MIC/Extensions-29057/SlicerJupyter/share/Slicer-4.11/qt-loadable-modules/JupyterKernel/Slicer-4.11 --replace --user"
Kernelspec install error output: "[InstallKernelSpec] Installed kernelspec slicer-4.11 in /home/sliceruser/.local/share/jupyter/kernels/slicer-4.11\n"

```

I was wondering if something is no longer compatible. I had to comment out COPY etc/dpkg…01\_nodoc in the Dockerfile to be able to build the container.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 18, 2020, 3:52am UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/4 "2020-12-18T03:52:05Z")

</div>

Can you build the image using the original, unmodified dockerfile?

---

<div class="post-metadata">

**Author:** ![Nadya\_Shusharina](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nadya_shusharina/32/9186_2.png) [@Nadya\_Shusharina](https://discourse.slicer.org/u/Nadya_Shusharina)\
**Post date:** [December 18, 2020, 2:28pm UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/5 "2020-12-18T14:28:02Z")

</div>

No. Same errors \_XSERVTransmkdir, QIODevice… Kernelspec as above when building using unmodified Dockerfile

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 22, 2020, 2:59pm UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/6 "2020-12-22T14:59:35Z")

</div>

I’ve checked and both errors that you see are harmless: I have those as well and the image works fine.

You can open a new terminal with the New button and check if you can find any clue in the system logs about why Slicer startup fails.

What CPU and graphics do you have in your system?

---

<div class="post-metadata">

**Author:** ![Nadya\_Shusharina](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/nadya_shusharina/32/9186_2.png) [@Nadya\_Shusharina](https://discourse.slicer.org/u/Nadya_Shusharina)\
**Post date:** [December 22, 2020, 10:04pm UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/7 "2020-12-22T22:04:41Z")

</div>

It is a CentOS7 headless VM sharing a Xeon E7-4830, with 4GB RAM, no GPU.

For a test, I have tried connecting the prebuilt container lassoan/slicer-notebook:2020-05-15-89b6bb5 to [https://example.com/](https://example.com/) directly. Just as before, I can start python 3.8 notebooks but not slicer notebook, as before:

```auto
[I 21:34:48.458 NotebookApp] Kernel started: c58312d4-31a6-4a7b-90e3-695e37eb2cb8, name: slicer-4.11
Switch to module: "Welcome"
Loading Slicer RC file [/home/sliceruser/.slicerrc.py]
Jupyter connection file: [/home/sliceruser/.local/share/jupyter/runtime/kernel-c58312d4-31a6-4a7b-90e3-695e37eb2cb8.json]
[W 21:35:48.846 NotebookApp] Timeout waiting for kernel_info reply from c58312d4-31a6-4a7b-90e3-695e37eb2cb8
error: [/home/sliceruser/Slicer-4.11.0-2020-05-14-linux-amd64/bin/SlicerApp-real] exit abnormally - Report the problem.
[I 21:35:54.450 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports

```

Can this be a low RAM issue?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 23, 2020, 1:23am UTC](https://discourse.slicer.org/t/running-slicer-notebook-docker-behind-https-reverse-proxy/15066/8 "2020-12-23T01:23:35Z")

</div>

4GB RAM is low and 4th generation Intel CPU is very old. You can open a new terminal using New button in the Jupyter GUI to inspect the system logs and see what fails. See for example [this similar topic](https://discourse.slicer.org/t/slicer-and-jupyter-kernel-dies-repeatedly-problem-with-connection/14965/18) (failure to start Slicer on a 3rd generation Intel CPU).

You can also try to just simply install Slicer on that computer and see if it starts.

I’ve also updated and tested a [notebook image](https://github.com/Slicer/SlicerDocker/tree/master/slicer-notebook) and tested that it works well.

Maybe you could make Slicer work by building it on your system instead of installing the pre-built package.
