How to run IPython behind an Apache proxy

前端 未结 6 1335
耶瑟儿~
耶瑟儿~ 2020-12-05 11:27

I would like to run an IPython notebook web server behind an Apache (reverse) proxy so that instead of the URL

https://my.server:XXXX

(where XXX

6条回答
  •  再見小時候
    2020-12-05 12:21

    I got this working using the following setup.

    IPython

    IPython Notebook is listening at http://localhost:8888/ipython. It was necessary to add the /ipython prefix, because IPython uses absolute paths, so it must be the same as the reverse proxied path.

    The ipython_notebook_config.py

    c = get_config()
    c.NotebookApp.ip = 'localhost'
    c.NotebookApp.open_browser = False
    c.NotebookApp.port = 8888
    c.NotebookApp.base_url = '/ipython'
    

    Apache

    I enabled

    • mod_proxy
    • mod_proxy_http
    • mod_proxy_wstunnel

    In the apache config I added

    
    ProxyPass        http://localhost:8888/ipython
    ProxyPassReverse http://localhost:8888/ipython
    ProxyPassReverseCookieDomain localhost my.server.com
    RequestHeader set Origin "http://localhost:8888"
    
    
    
    ProxyPass        ws://localhost:8888/ipython/api/kernels/
    ProxyPassReverse ws://localhost:8888/ipython/api/kernels/
    
    

    to an SSL enabled virtual host definition.

    The RequestHeader set Origin "http://localhost:8888" was necessary for the websockets, otherwise you get a 403 Forbidden.

    Now IPython is reachable at https://my.server.com/ipython (no trailing /!).

提交回复
热议问题