Reverse Proxy
It is occasionally necessary to run interactive software on Turing which is accessed via a web interface. This can be accomplished through the OpenOnDemand reverse proxy.
OpenOnDemand
Turing's Open OnDemand instance supports acting as a reverse proxy for things running on compute nodes. It has two simialar versions of the endpoint:
https://ondemand.turing.wpi.edu/node/<node>.cm.cluster/<port>
https://ondemand.turing.wpi.edu/rnode/<node>.cm.cluster/<port>
The difference between the two is that node
passes the path through unchanged, while rnode
strips off the excess path components.
Example
Pick a random port
$ WEB_PORT=$(free_port $((10000+RANDOM%10000))) # (1)! (2)!
$ echo "Connect at https://ondemand.turing.wpi.edu/node/$HOSTNAME.cm.cluster/$WEB_PORT"
$ python serve.py $WEB_PORT
2. You can also use the free_port
program provided by the wpi-scripts
module. This will start with the provided one, and consecutively test ports until it finds an open one, returning that number.
from http.server import BaseHTTPRequestHandler, HTTPServer
import sys
class SimpleHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.end_headers()
self.wfile.write(f"You queried path: {self.path}".encode())
if __name__ == '__main__':
port = int(sys.argv[1])
server = HTTPServer(('0.0.0.0', port), SimpleHandler)
print(f"Serving on http://0.0.0.0:{port}")
server.serve_forever()
In this example, if I then visit the site, it reports the connected path
# Connecting with node
- Visit https://ondemand.turing.wpi.edu/node/compute-2-02.cm.cluster/18623/gompei
- Returns "You queried path: /node/compute-2-02.cm.cluster/18623/gompei"
- Python logs 10.128.147.168 - - [28/Jul/2025 11:03:59] "GET /node/compute-2-02.cm.cluster/18623/gompei HTTP/1.1" 200 -
# Connecting via rnode
- Visit https://ondemand.turing.wpi.edu/rnode/compute-2-02.cm.cluster/18623/gompei
- Returns "You queried path: /gompei"
- Python logs 10.128.147.168 - - [28/Jul/2025 11:03:59] "GET /gompei HTTP/1.1" 200 -