Hi all,
I've been beating my head against the wall for hours over this now. I'd like
to run Sage Notebook server from my home server, which also has a few other
web based apps running through Apache. Obviously, I want to enable ssl --
and I already have a certificate for my own domain that I'm using to run
those other apps.
This is going to be a long post, so I'll get straight to the questions first
in case someone already knows the answer. My goal is to be able to go to
https://www.mydomain.com/sage in order to use the sage notebook server.
1. Is there a way to set the context path for the Sage notebook server?
What I mean is, normally you have browse to http://127.0.0.1:8000 to get
to the notebook server, but is there a setting that will allow you to go to
http://127.0.0.1:8000/sage to see it?
2. If that's not possible, what are the exact apache config settings I
need to use to get reverse proxy running correctly. Other sources (
http://wiki.sagemath.org/SageServer) don't consider an environment with
other web services. What if I'm already using reverse proxy for another
service?
3. If that's not possible (or nobody knows) -- I have my own ssl
certificate that I got from startssl.com. How can I get Sage to use my
verified certificate rather than the one it generates?
First off, my setup uses two VBox virtual machines -- one Ubuntu 10.04
(64-bit), and one Windows 2008 R2 (64-bit). The physical server is Ubuntu
8.04 (AMD64, 64-bit). The Ubuntu VM is running Apache2 and subversion, and
the Windows VM is running a bunch of media services. What I'm trying to do
is run Sage on the physical server, and use Apache2 on the Ubuntu VM as the
gateway for it. The reason why is that I'm already using Apache2 as a
gateway to other services on my Windows VM, so port 443 is already forwarded
to the Ubuntu VM. (Why am I running Apache in a VM? Uhm...long story. It
doesn't really matter for this.)
This page (http://wiki.sagemath.org/SageServer) makes a recommendation that
doesn't work for my setup. Here's the relevant Apache config section:
ServerName YOUR_SERVER_NAMEProxyRequests
OffProxyPreserveHost OnOrder deny,allowAllow from allProxyPass
/ http://localhost:8000/ProxyPassReverse / http://localhost:8000/ DocumentRoot
/DefaultType text/htmlErrorLog
/var/log/apache2/error.log # Possible values include: debug, info, notice,
warn, error, crit, # alert, emerg. LogLevel warn CustomLog
/var/log/apache2/access.log combined ServerAdmin
YOUR_SERVER_ADMIN_EMAIL_ADDRESS
The problem with this is that ProxyPass and ProxyPassReverse both send *
everything* to the sage notebook server. This is for a setup with a
dedicated domain; i.e., http://www.mydomain.com will be the url for sage. I
want to use https://www.mydomain.com/sage.
In order to do that I first tried these directives in the "default-ssl"
config file:
ProxyPass /sage http://192.168.2.140:8000/ProxyPassReverse /sage
http://192.168.2.140:8000/
The problem with this is that all of the links in the html work improperly,
meaning images, css, and javascript don't load. The reason is that the html
uses paths like "/path/to/image.png", which gets resolved on the client side
to https://www.mydomain.com/path/to/image.png instead of
https://www.mydomain.com/sage/path/to/image.png. This also means that the
submit button for the login directs to https://www.mydomain.com/home instead
of https://www.mydomain.com/sage/home.
I think the easiest fix for this is if there was some setting in Sage that
allows you (on the local network) to browse to http://192.168.2.140/sage.
This is what my music server does -- it allows me to change the context
path. The directives I use for that (which work perfectly) are:
ProxyPass /music http://192.168.2.140:8181/musicProxyPassReverse /music
http://192.168.2.140:8181/music
Okay, so I tried working around this problem. I discovered that I should be
able to use mod_proxy_html to resolve URIs properly. I used information from
these two sites (http://wlug.org.nz/ApacheReverseProxy and
http://www.apachetutor.org/admin/reverseproxies) to come up with a
configuration that works sort of half way. (Following the config directives
of either site by itself either resulted in the same issues or the notebook
server being totally inaccessible.) Here's the config I used:
ProxyPass /sage/ http://192.168.2.140:8000/
ProxyHTMLURLMap http://192.168.2.140:8000 /sage
Order deny,allow
Allow from all
ProxyPassReverse /
SetOutputFilter proxy-html
ProxyHTMLURLMap / /sage/
At first, when I browse to https://www.mydomain.com/sage/ I found success!
The css, images, and everything loaded properly! But when I try to log in,
for some reason I get redirected to http://192.168.2.140:8000/. I just don't
understand why this happens, and I've tried playing a