Custom preview URL for SSH workspace


I have a ssh server where I am using c9 for any quick patches or sometimes development.

I have been struggling to use a preview running application with project specific url. It always open ip address in browser.

Since I have more than one application, I don’t want to entertain $port variable in it. I am guessing that c9 must be able to specify the base url for ssh workspaces. So instead of IP address, I can use base url per project for preview.

Please let me know where I can do it.

I would like to be able to specify base url for application in ssh workspace per project like for my site for my other site

Both are running on same server



Hi, this is something you need to configure outside of C9 - if you want to be using several services on the machine I recommend setting up nginx which proxies to the node service. I haven’t read the full article but believe this explains it well:

Happy coding!


Thanks for your reply but this doesn’t answer me how to change preview url to something other than IP address in ssh workspace.


We can add previewURL to project settings and use it in

but until it is implemented you can add the following code snippet to your user script (using cloud9 menu)

var cmd = services.commands.commands.preview; 
cmd.exec_orig = cmd.exec_orig || cmd.exec
cmd.exec = function(editor, args) {
   if (args.server) {
       args.path = location.protocol
           + "//" // can be changed based on services.c9.projectName
       args.server = null
   cmd.exec_orig(editor, args)


Thanks for your reply.

I presumed that you were talking about init.js script from c9 menu. I added it but unfortunately it didn’t work.



Hey @VarunBatraIT,

Try not using C9’s preview URL and instead just go to the path on the domain you except to see your app. For example I host this C9 SSH Workspace and when I make updates to it I just check the domain name in a separate tab for changes I’ve just made to the server:

For complete reference, here’s the docs on SSH Workspaces in Cloud9:

a couple extras:

:books: :snail:


I meant init.js, but i had a typo in the script, please try the updated version


This works great. Except that it doesn’t work on https because I don’t have ssl. When I removed protocol, it only works with sauce labs browsers and not core browsers. I am assuming it is a protocol error which is understandable. I can live with sauce lab. Thanks for the snippet.