# Containers with Apache Reverse Proxy + JupyterHub

**URL:** <https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297>\
**Category:** JupyterHub\
**Tags:** jupyterhub, help-wanted\
**Created:** [July 30, 2024, 6:11pm UTC](https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297 "2024-07-30T18:11:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![writingindy](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@writingindy](https://discourse.jupyter.org/u/writingindy)\
**Post date:** [July 30, 2024, 6:11pm UTC](https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297/1 "2024-07-30T18:11:16Z")

</div>

Hi,

I have a working setup for JupyterHub that runs in a container as well as another container that deploys a website using Apache. The container with the Apache website has SSL certs and uses ProxyPass and ProxyPassReverse to serve another service that runs in a third separate container.

The website’s URL is `https://host-website.ca`. Right now, people have access to the third service when they go to `https://host-website.ca/service/`, and I want JupyterHub to show up when people go to `https://host-website.ca/hub/`.

In the JupyterHub container, I’ve launched JupyterHub and it says that it’s now running at `http://internal-jupyterhub-ip:8000/` , so I was hoping to be able to use ProxyPass and ProxyPassReverse to serve JupyterHub as well by adding these lines in my Apache conf:

```auto
ProxyPass /hub/ http://internal-jupyterhub-ip:8000/
ProxyPassReverse /hub/ http://internal-jupyterhub-ip:8000/

```

My JupyterHub configuration looks something like this:

```auto
c.JupyterHub.ip = 'internal-jupyterhub-ip'
c.JupyterHub.port = 8000
c.JupyterHub.hub_ip = '192.168.152.97'
c.JupyterHub.hub_connect_ip = '192.168.152.97'

```

When I go to `https://host-website/hub/`, it shows this:

 ![Screenshot from 2024-07-30 14-04-20](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/5/5b90564e6ee030deef9eb6326cfe94d6f9bacf6c.png)  
and looking at the logs for JupyterHub, it appears to be stuck in some redirect loop?

```auto
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.399 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 3.41ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.427 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 6.06ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.444 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 3.03ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.462 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.84ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.488 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.77ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.506 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.76ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.534 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.82ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.551 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.75ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.569 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.89ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.599 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.73ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.621 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.74ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.643 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.89ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.659 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.72ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.687 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.77ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.705 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.74ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.724 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.71ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.740 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.69ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.760 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.80ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.780 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.88ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.798 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.77ms
Jul 30 18:06:26 jupyterhub jupyterhub[4550]: [I 2024-07-30 18:06:26.816 JupyterHub log:192] 302 GET / -> /hub/ (@192.168.152.10) 2.73ms

```

Any help on this would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![writingindy](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@writingindy](https://discourse.jupyter.org/u/writingindy)\
**Post date:** [July 30, 2024, 6:31pm UTC](https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297/2 "2024-07-30T18:31:35Z")

</div>

I tried adding `c.JupyterHub.base_url ='/jupyterhub/'` to the JupyterHub configuration file, and now when I go to `https://host-website.ca/hub/` it redirects me to `host-website.ca/jupyterhub/hub/` and gives a 404 Not Found error.

Pretty sure this is just a problem with me not understanding how to setup the JupyterHub configuration properly, but I’m not sure what else to try (based on what I’ve seen on past JupyterHub forum posts).

---

<div class="post-metadata">

**Author:** ![writingindy](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@writingindy](https://discourse.jupyter.org/u/writingindy)\
**Post date:** [July 30, 2024, 6:43pm UTC](https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297/3 "2024-07-30T18:43:46Z")

</div>

Did some more digging - and solved my own problem (I guess sometimes just writing down what’s happening can help with debugging!)

I had to set the `c.JupyterHub.bind_url` to be `https://internal-jupyterhub-ip:8000/jupyter/` and for the Apache configuration have the lines:

```auto
ProxyPass /jupyter/ http://internal-juptyerhub-ip:8000/jupyter/
ProxyPassReverse /jupyter/ http://internal-jupyterhub-ip:8000/jupyter/

```

and it works!

---

<div class="post-metadata">

**Author:** ![writingindy](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@writingindy](https://discourse.jupyter.org/u/writingindy)\
**Post date:** [July 30, 2024, 8:11pm UTC](https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297/4 "2024-07-30T20:11:51Z")

</div>

So what I did works, as in I can login and request a job through Slurm + JupyterHub, but when I try to run some code it just hangs? I tried to open a terminal and it also just is stuck loading the terminal.

There’s a lot of information online about using Apache as a reverse proxy and JupyterHub but it seems pretty old. Our Apache version is 2.4.52, and I’m not sure what’s relevant in terms of getting things to work.

If there’s anything needed (logs, config files) to help figure out why this is happening, please let me know and I’ll provide it!

---

<div class="post-metadata">

**Author:** ![writingindy](https://avatars.discourse-cdn.com/v4/letter/w/bbe5ce/32.png) [@writingindy](https://discourse.jupyter.org/u/writingindy)\
**Post date:** [July 30, 2024, 9:34pm UTC](https://discourse.jupyter.org/t/containers-with-apache-reverse-proxy-jupyterhub/27297/5 "2024-07-30T21:34:28Z")

</div>

I just followed the instructions [Using a reverse proxy — JupyterHub documentation](https://jupyterhub.readthedocs.io/en/stable/howto/configuration/config-proxy.html) and it worked! Solved!
