我有一台运行ubuntu + apache的服务器。我有一个运行的网站(带有多用户黑客的旧ipython笔记本),可以通过xxx.xx.xx.xx(=:myip)访问。相应的名为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 jupyterhub
和sudo service apache2 reload
,则新网站会在http://myip:9111下按预期运行。但是,地址为http://myip的旧网站会显示服务不可用。
我不明白我需要改变什么才能让两个网站同时运作。有什么帮助吗?
编辑:
我相信我需要将jupyterhub配置放在<VirtualHost *:9111>
内,但如果我启动jupyterhub服务器则说明了
代理似乎在http://myip:9111运行,但我无法访问它。连接被拒绝。
答案 0 :(得分:1)
好的,所以诀窍就像我假设的那样:它需要放在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>