Run cloud9 under subdirectory


#1

Is it possible to configure cloud9 to run under a subdirectory, like /cloud9? I’ve searched around but haven’t really found a definitive answer. I tried using nginx with subs_filter to rewrite the HTML, but I still get links to things like /static, for example. Seems like it would be easier if there was a way to change this in the application through a config variable or something.


#2

Not sure what you are asking.


#3

The default is for cloud9 SDK to use the root (ex. http://localhost:80/). I would like to be able to move it to something like http://localhost:80/cloud9.


#4

And now I have this same question. Anyone got an answer?

By the way, I’m sure OP is talking about running the SDK on a home server or some such.


#5

This is what I’ve tried using in my site profile (000-default.conf) so far:

<VirtualHost *:80>
	ServerAdmin admin@example.com
	DocumentRoot /var/www/html

	ServerName example.com
	ServerAlias www.example.com

	Redirect / https://example.com/
</VirtualHost>

<VirtualHost *:443>
	SSLEngine On
	SSLCertificateFile    /etc/letsencrypt/live/example.com/cert.pem
	SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem

	ProxyPreserveHost On
	ProxyPass /c9 http://127.0.0.1:8080/
	ProxyPassReverse /c9 http://127.0.0.1:8080/
</VirtualHost>

The strange thing is that when I try going to www.example.com/c9, I’ll get the login prompt (as I set my SDK server to require credentials) but after entering my creds, it takes me to www.example.com/ide.html and gives me a 404 (Page not found) error.


#6

Anyone got any ideas?


#7

No one knows how to change the context path when running the cloud9 sdk server?


#8

it is not possible without changing sdk source code https://github.com/c9/core/issues/11#issuecomment-151846177


#9

Thank you.

Guess I’ll be sifting through the source code for a while…


#10

Did you figure out anything?


#11

Personally, I’m just using a subdomain (c9.example.com). It’s quite easier that way.


#12

Hey, could you tell me how to do that? Does this bypass needing a port other than 80/443?


#13

Yes. You’ll only need to forward ports 80/443 on your router. I’m also using PM2 to keep the Node.js server running. It adds a bit of stability. So I’ll start the server with this:

$ pm2 start /home/user/c9core/server.js -- -w ~/workspace/ -l 0.0.0.0 -p 8080 -a user:password
$ pm2 startup systemd

Now the server is running and listening. You can check with pm2 status (if you’re using PM2). You can also verify with netstat -pant | grep 8080. Of course, you can use whatever other port you want.

Now I’m using Nginx for a web server, so I can only give you a config file for that & not Apache. Nginx is being used as a reverse proxy here and it just forwards requests for c9.example.com over to the localhost process that’s listening on port 8080. I could have started the Node.js server to listen only on 127.0.0.1, but I wanted the option of directly accessing it while I was at home.

server {
        listen 80;
        listen [::]:80;

        root /var/www/html;

        server_name c9.example.com;
        return 301 https://$server_name$request_uri;
}

server {
        listen 443 ssl;
        listen [::]:443 ssl;

        root /var/www/html;
        server_name c9.example.com;

        include snippets/ssl-example.com.conf;
        include snippets/ssl-params.conf;

        location / {
                proxy_pass http://192.168.1.2:8080;
        }
}

Hope that helps.


#14

Aha. Thanks for the instructions. Unfortunately, unless I’m missing something, still not a solution for shared hosting. 1) I don’t have nginx. 2) I don’t have access to the web server configuration files. and 3) In this scenario, can I still have other other domains on the same server accessible through ports 80/443?


#15
  1. Should work fine for Apache or whatever else you’re using.
  2. Can’t help you there.
  3. Yes, look up virtual hosts for whatever web server you’re using. But if you can’t change the web server configuration, then there isn’t much you can do…