Apache虚拟主机+反向代理冲突

Apache virtual host + reverse proxy conflict

我有一个服务器 运行ning ubuntu+apache。我有一个可以通过 xxx.xx.xx.xx (=:myip) 访问的网站 运行ning(带有多用户黑客的旧 ipython 笔记本)。名为 sins.conf 的相应 apache 配置如下所示:

<VirtualHost *:80>
    ServerName ipython.local-server
    ServerAlias

    WSGIDaemonProcess ipythonapp2 user=www-data group=www-data processes=2 threads=5\
     python-path=/home/sins/ilmrt/lib/python2.7/site-packages
    WSGIScriptAlias / /home/sins/ilmrt/ipysite/wsgi.py
    <Directory /home/sins/ilmrt/ipysite>
    #WSGIProcessGroup ipythonapp2
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
        Allow from all
    </Directory>
    Alias /static/ /home/sins/ilmrt/ipysite/static/
    <Location "/static/">
        Options -Indexes
    </Location>
</VirtualHost>

并且工作完美。

现在,由于我即将 运行 一个带有反向代理的新网站 (jupyterhub),我设置了一个名为 jupyterhub.conf:

的新 apache 配置
ProxyPass / http://localhost:9111/
ProxyPassReverse / http://localhost:9111/

Header edit Origin http://myip:9111/ localhost:9111
RequestHeader edit Origin http://myip:9111 localhost:9111

Header edit Referer http://myip:9111  localhost:9111
RequestHeader edit Referer http://myip:9111 localhost:9111
<Location ~ "/(user/[^/]*)/(api/kernels/[^/]+/channels|terminals/websocket)/?">
    ProxyPass ws://localhost:9111
    ProxyPassReverse ws://localhost:9111
</Location>

如果我 运行 sudo a2ensite jupyterhubsudo service apache2 reload,新网站在 http://myip:9111. However, the old website with the address http://myip 下按预期工作显示 服务不可用

我不明白我需要更改什么才能使两个站点同时工作。有帮助吗?

编辑: 我相信我需要将 jupyterhub 配置放在 <VirtualHost *:9111> 中,但是如果我启动 jupyterhub 服务器,它会显示
代理似乎 运行 正在 http://myip:9111,但我无法访问它。连接被拒绝。

好吧,技巧和我想的一样:它需要放在 VirtualHost 中。 出于某种原因,我最初在下面的配置代码前面放了一个 Listen 9111,这就是它阻止某些东西的原因。这里是代码以防有人感兴趣:

<VirtualHost *:9111>
    ProxyPass / http://localhost:9111/
    ProxyPassReverse / http://localhost:9111/

    Header edit Origin http://myip:9111/ localhost:9111
    RequestHeader edit Origin http://myip:9111 localhost:9111

    Header edit Referer http://myip:9111  localhost:9111
    RequestHeader edit Referer http://myip:9111 localhost:9111

    <Location ~ "/(user/[^/]*)/(api/kernels/[^/]+/channels|terminals/websocket)/?">
        ProxyPass ws://localhost:9111
        ProxyPassReverse ws://localhost:9111
    </Location>

    LogLevel debug
</VirtualHost>