# Unable to get git hub oauth work on a jupyterhub server which is behind a proxy

**URL:** <https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334>\
**Category:** JupyterHub\
**Tags:** how-to, help-wanted\
**Created:** [October 12, 2020, 5:15pm UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334 "2020-10-12T17:15:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![VamsiKrishna\_Vankaya](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/vamsikrishna_vankaya/32/2874_2.png) [@VamsiKrishna\_Vankaya](https://discourse.jupyter.org/u/VamsiKrishna_Vankaya)\
**Post date:** [October 12, 2020, 5:15pm UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/1 "2020-10-12T17:15:54Z")

</div>

My Jupyterhub server is behind a proxy in a DMZ. I am able to set up the hub server. however while i run the git hub auth I get the following error:

[E 2020-10-12 09:40:58.565 JupyterHub web:1792] Uncaught exception GET /hub/oauth\_callback?code=5fa9a45d536540819884&state=eyJzdGF0ZV9pZCI6ICI0YmMwZWVlYjI1ZDc0NDg5YWMxZDEyNTdjODg5ZjY2ZiIsICJuZXh0X3VybCI6ICIifQ%3D%3D (194.39.131.5)  
HTTPServerRequest(protocol=‘http’, host=‘[my.host.com](http://my.host.com)’, method=‘GET’, uri=’/hub/oauth\_callback?code=5fa9a45d536540819884&state=eyJzdGF0ZV9pZCI6ICI0YmMwZWVlYjI1ZDc0NDg5YWMxZDEyNTdjODg5ZjY2ZiIsICJuZXh0X3VybCI6ICIifQ%3D%3D’, version=‘HTTP/1.1’, remote\_ip=‘194.39.131.5’)  
Traceback (most recent call last):  
File “/usr/local/lib/python3.6/dist-packages/tornado/web.py”, line 1703, in \_execute  
result = await result  
File “/usr/local/lib/python3.6/dist-packages/oauthenticator/oauth2.py”, line 213, in get  
user = await self.login\_user()  
File “/usr/local/lib/python3.6/dist-packages/jupyterhub/handlers/base.py”, line 699, in login\_user  
authenticated = await self.authenticate(data)  
File “/usr/local/lib/python3.6/dist-packages/jupyterhub/auth.py”, line 383, in get\_authenticated\_user  
authenticated = await maybe\_future(self.authenticate(handler, data))  
File “/usr/local/lib/python3.6/dist-packages/oauthenticator/sapgithub.py”, line 141, in authenticate  
resp = await http\_client.fetch(req)  
File “/usr/local/lib/python3.6/dist-packages/tornado/simple\_httpclient.py”, line 336, in run  
source\_ip=source\_ip,  
File “/usr/local/lib/python3.6/dist-packages/tornado/tcpclient.py”, line 270, in connect  
addrinfo = await self.resolver.resolve(host, port, af)  
File “/usr/local/lib/python3.6/dist-packages/tornado/netutil.py”, line 396, in resolve  
None, \_resolve\_addr, host, port, family  
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run  
result = self.fn(\*self.args, \*\*self.kwargs)  
File “/usr/local/lib/python3.6/dist-packages/tornado/netutil.py”, line 379, in \_resolve\_addr  
addrinfo = socket.getaddrinfo(host, port, family, socket.SOCK\_STREAM)  
File “/usr/lib/python3.6/socket.py”, line 745, in getaddrinfo  
for res in \_socket.getaddrinfo(host, port, family, type, proto, flags):  
socket.gaierror: [Errno -2] Name or service not known

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [October 12, 2020, 6:54pm UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/2 "2020-10-12T18:54:23Z")

</div>

> [@VamsiKrishna\_Vankaya](#):
>
> socket.gaierror: [Errno -2] Name or service not known

It sounds like your OAuth server can’t be reached. Have you verified that your network routing, firewall, and DNS are all correct?

---

<div class="post-metadata">

**Author:** ![VamsiKrishna\_Vankaya](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/vamsikrishna_vankaya/32/2874_2.png) [@VamsiKrishna\_Vankaya](https://discourse.jupyter.org/u/VamsiKrishna_Vankaya)\
**Post date:** [October 13, 2020, 3:35am UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/3 "2020-10-13T03:35:57Z")

</div>

@manics Thanks so much. Yes i am unable to reach the OAuth server. A simple curl showed me that. But how do i use jupyterhub in a DMZ? The only way to access outside network is via a DMZ proxy. Is there a way to do it?

---

<div class="post-metadata">

**Author:** ![VamsiKrishna\_Vankaya](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/vamsikrishna_vankaya/32/2874_2.png) [@VamsiKrishna\_Vankaya](https://discourse.jupyter.org/u/VamsiKrishna_Vankaya)\
**Post date:** [October 13, 2020, 4:08am UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/4 "2020-10-13T04:08:44Z")

</div>

@manics I added the ip of the github server to /etc/hosts to fix the resolver issues. I am using the jupyterhub behind an NGINX reverse proxy which is able to reach the github server. Its when the redirect happens from the enterprise github that I get this error:

[D 2020-10-12 23:46:57.001 JupyterHub log:174] 304 GET /hub/logo (@194.39.131.5) 0.79ms  
[I 2020-10-12 23:47:00.374 JupyterHub oauth2:103] OAuth redirect: ‘mydothostdotcom/hub/oauth\_callback’  
[I 2020-10-12 23:47:00.375 JupyterHub log:174] 302 GET /hub/oauth\_login?next= -\> myenterprisegithub/login/oauth/authorize?response\_type=code&redirect\_uri=https%3A%2F%2Fmydothostdotcom%2Fhub%2Foauth\_callback&client\_id=455853a518ec4809c1fa&state=[secret] (@194.39.131.5) 1.53ms  
[E 2020-10-12 23:47:10.027 JupyterHub web:1792] Uncaught exception GET /hub/oauth\_callback?code=18521fda182fe7446e55&state=eyJzdGF0ZV9pZCI6ICIyZWNhYzY0MzViMzk0ZWQ2ODE1MDNhNzZlNjlhMzAxMyIsICJuZXh0X3VybCI6ICIifQ%3D%3D (194.39.131.5)  
HTTPServerRequest(protocol=‘http’, host=‘mydothostdotcom’, method=‘GET’, uri=’/hub/oauth\_callback?code=18521fda182fe7446e55&state=eyJzdGF0ZV9pZCI6ICIyZWNhYzY0MzViMzk0ZWQ2ODE1MDNhNzZlNjlhMzAxMyIsICJuZXh0X3VybCI6ICIifQ%3D%3D’, version=‘HTTP/1.1’, remote\_ip=‘194.39.131.5’)  
Traceback (most recent call last):  
File “/usr/local/lib/python3.6/dist-packages/tornado/web.py”, line 1703, in \_execute  
result = await result  
File “/usr/local/lib/python3.6/dist-packages/oauthenticator/oauth2.py”, line 213, in get  
user = await self.login\_user()  
File “/usr/local/lib/python3.6/dist-packages/jupyterhub/handlers/base.py”, line 699, in login\_user  
authenticated = await self.authenticate(data)  
File “/usr/local/lib/python3.6/dist-packages/jupyterhub/auth.py”, line 383, in get\_authenticated\_user  
authenticated = await maybe\_future(self.authenticate(handler, data))  
File “/usr/local/lib/python3.6/dist-packages/oauthenticator/sapgithub.py”, line 141, in authenticate  
resp = await http\_client.fetch(req)  
OSError: [Errno 113] No route to host

[D 2020-10-12 23:47:10.029 JupyterHub base:1197] No template for 500  
[E 2020-10-12 23:47:10.034 JupyterHub log:166] {  
“X-Forwarded-Host”: “[my.host.com](http://my.host.com)”,  
“X-Forwarded-Proto”: “http”,  
“X-Forwarded-Port”: “80”,  
“Cookie”: “rxVisitor=[secret]; dtCookie=[secret]; dtSa=[secret]; dtLatC=[secret]; dtPC=[secret]; rxvt=[secret]; oauthenticator-state=[secret]”,  
“Accept-Language”: “en-US,en;q=0.9”,  
“Accept-Encoding”: “gzip, deflate, br”,  
“Referer”: “my.idp.service”,  
“Sec-Fetch-Dest”: “document”,  
“Sec-Fetch-Mode”: “navigate”,  
“Sec-Fetch-Site”: “cross-site”,  
“Accept”: “text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,_/_;q=0.8,application/signed-exchange;v=b3;q=0.9”,  
“User-Agent”: “Mozilla/5.0 (Macintosh; Intel Mac OS X 10\_15\_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.123 Safari/537.36”,  
“Upgrade-Insecure-Requests”: “1”,  
“Cache-Control”: “max-age=0”,  
“Connection”: “close”,  
“X-Forwarded-For”: “194.39.131.5,::ffff:127.0.0.1”,  
“Host”: “[my.host.com](http://my.host.com)”,  
“X-Real-Ip”: “194.39.131.5”  
}

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [October 13, 2020, 6:57pm UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/5 "2020-10-13T18:57:32Z")

</div>

There’s an issue on the oauthenticator repo about enabling a HTTP(S) proxy:

> <https://github.com/jupyterhub/oauthenticator/issues/217#issuecomment-492572502>
>
> I think there is something preventing CurlAsyncHTTPClient from accepting defaults.
> AsyncHTTPClient.configure("tornado.curl\_httpclient.CurlAsyncHTTPClient", defaults=defaults) didn't work from config.yaml.
> I had to do this hack:
> extraConfig:...

Maybe it will help?

---

<div class="post-metadata">

**Author:** ![VamsiKrishna\_Vankaya](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/vamsikrishna_vankaya/32/2874_2.png) [@VamsiKrishna\_Vankaya](https://discourse.jupyter.org/u/VamsiKrishna_Vankaya)\
**Post date:** [October 14, 2020, 6:12am UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/6 "2020-10-14T06:12:24Z")

</div>

> [@manics](#):
>
> Couldn’t get the proxy to work

Thank you @manics. Being a little new to Jupyterhub I want to know where to add the the piece of code suggested by dtanderson in [Configuring web-requests to use a proxy · Issue #217 · jupyterhub/oauthenticator · GitHub](https://github.com/jupyterhub/oauthenticator/issues/217)? Will it be in jupyterhub\_config.py or the app.py?

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [October 18, 2020, 5:34pm UTC](https://discourse.jupyter.org/t/unable-to-get-git-hub-oauth-work-on-a-jupyterhub-server-which-is-behind-a-proxy/6334/7 "2020-10-18T17:34:47Z")

</div>

You should add it to your `jupyterhub_config.py` assuming you’re managing JupyterHub yourself. If you’re using a distribution of JupyterHub such as Z2JH this may be different.
