Setting up Sage and Apache
This page is discusses how to configure the Sage server to work with Apache. All configurations are using Apache 2.0 on OpenSuse 11.0. Configurations should work with other operating systems, but file locations and names may differ.
Why use Apache?
Sage runs it's own web server using the Python Twisted Framework, by default serving web pages on port 8000. The port number can be changed by specifying the port number when starting the notebook server. However all ports up to and including port 1000 require root privileges to use, and running Sage as root poses serious security risks to the server it is running on. Since often times firewalls are in place the block any ports Sage has available as non-root user it would be nice to be able to serve the Sage interface on a common port ideally port 80.
Apache's Mod Proxy module allows you to create a reverse proxy that you can use to server Sage on port 80. To use it make sure that the module is being loaded by Apache. In OpenSuse this can be configured through Yast and can be checked in /etc/apache2/sysconfig.d/loadmodule.conf and should contain the line:
LoadModule proxy_module /usr/lib/apache2-prefork/mod_proxy.so
The files location may be different on other operating system, check your operating systems Apache documentation.
The following lines need to be added to your httpd.conf file.
ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> <VirtualHost *> ServerName myserver.com ProxyPass / http://localhost:8000/ ProxyPassReverse / http://localhost:8000/ <Location /> DefaultType text/html </Location> </VirtualHost> ServerName myserver.com
Replace myserver.com with the hostname of your server. The / on ProxyPass and ProxyPassReverse means that the root directory needs to be forwarded to Sage if you wanted to have a subdirectory called Sage be the address that is forwarded replace / with /Sage.