Run A Webserver¶
For testing and development, it is possible to run a small webserver inside a CoCalc project. Access to it is restricted to only the owner and all collaborators on the project, and nobody else.
Given your project’s ID is [project_id] like
and the service is serving on [port],
and it is serving to all ip addresses (not just localhost!), then use:
to access your HTTP web server.
For example, you might have to start the service using
--ip=0.0.0.0 to serve all IPs
(the exact flag depends on the service).
If the webserver directs the client to make additional requests to the backend for absolute URL’s, e.g., the service serves a file index.html like this
then when you click on the link, your browser will try to grab
Obviously, this can’t possibly work.
Many webservers, e.g., tensorboard, work fine and do not do this. Others won’t work without modification.
Using the port proxy¶
This is similar to above (
port instead of
When you visit that URL with your web browser, your web server will get a request for
/[project_id]/port/[port]/ rather than for
/ as it does with server.
Otherwise, everything is the same, including the warning above.
What about security?¶
Only the owner and collaborators on the given project can access the webserver via an SSL encrypted connection. Our proxy server will reject all other requests. This means you don’t have to worry about setting up logins/passwords on whatever webserver you run in your project. On the other hand, it means that CoCalc is not useful as a platform if you want to run a webserver that is visible to anybody in the world. If you need that, use some other service.
What about dynamically generated subdomains?¶
Obviously, it would be nice if we could map a project_id and port to a subdomain like
We have not implemented this.
Here’s a simple example of an HTTP server written using the Python SimpleHTTPServer class. Open a project and click “+New” then paste in this link, then click the “From Web” button (or use wget or copy/paste into a file):
Then in a terminal type:
Raw Files Server¶
If you just want an https view of your files, use the raw server, which is already available by default at
https://cocalc.com/[project_id]/raw/. The point of the above is that you could modify it to provide all sorts of interesting functionality.