code-server icon indicating copy to clipboard operation
code-server copied to clipboard

base url support

Open majikxu opened this issue 7 years ago • 25 comments

I wanne run behind proxy

majikxu avatar Mar 14 '19 16:03 majikxu

@yamajik I think there are already docs on how to run it behind a proxy https://github.com/codercom/code-server/blob/master/doc/self-hosted/index.md#user-content-nginx-reverse-proxy

MichaelDesantis avatar Mar 14 '19 16:03 MichaelDesantis

I am managing many code servers behind a proxy. Each server serves with baseurl like “/code-server/:server_id/“ . But, some requests still do from root.

majikxu avatar Mar 15 '19 01:03 majikxu

I wanne config for global baseurl setting

majikxu avatar Mar 15 '19 01:03 majikxu

I just found code-server, and I want to give it a try, but without base url support it looks like I'll have to setup a separate subdomain for it on my website, which is pretty inconvenient.

tiffany352 avatar Mar 15 '19 05:03 tiffany352

@tiffany352 @yamajik have you tried using Docker with different IPs to see if it works as a temporary workaround? This is possible by creating a new network.

sr229 avatar Mar 15 '19 14:03 sr229

I also request this. It's a non-starter if I can't use it at another HTTP path, instead of /.

@sr229 that won't help. The issue is that you cannot set it up to be at http://myserver.foo/vscode/, rather it must be at http://myserver.foo/

mgcaret avatar Mar 15 '19 15:03 mgcaret

I also would like this functionality to be added in, preferably as an environment variable such as BASE_URL

LetsEncrypt limits the number of SSL certs for subdomains on one host, thus taking up another subdomain is not preferable.

sgama avatar Mar 15 '19 20:03 sgama

@sgama Off topic, but I'm kind of confused about your LE comment, I don't see any kind of limit other than (large) rate limits on certificate issuing? There's also wildcard certificates available now.

I ended up just making a new subdomain to run code-server on, and it's working fine.

tiffany352 avatar Mar 16 '19 03:03 tiffany352

@tiffany352, oh right. Wildcards are available now. Thanks for reminding me.

sgama avatar Mar 16 '19 04:03 sgama

This should be fixed. The socket should now be created at the current page path.

kylecarbs avatar Mar 17 '19 01:03 kylecarbs

Not sure.

resourse urls webview urls ...

Both incorrect.

I have fixed some in my fork.

majikxu avatar Mar 19 '19 07:03 majikxu

reopen this, plz.

majikxu avatar Mar 19 '19 07:03 majikxu

I will pr my fix later which may not fix all.

majikxu avatar Mar 19 '19 07:03 majikxu

+1

chylvina avatar Mar 19 '19 07:03 chylvina

We'll have to remove the /resource and replace it with resource/ to use subpaths.

kylecarbs avatar Mar 19 '19 18:03 kylecarbs

+1 this will be a big help for us

patrickstjohn avatar Mar 25 '19 01:03 patrickstjohn

@yamajik Thank you for the PR to add this feature. Any documentation on how we utilize this? Looking at your code it seems like you are fixing up the URLs? So if we have a server running behind a proxy pointing at something like http:///patrickstjohn it would strip off patrickstjohn and things would work as if you were going to / directly?

patrickstjohn avatar Apr 17 '19 14:04 patrickstjohn

Index page is redirecting http://hostname/custombaseurl/ to http://hostname/login/ when it should be http://hostname/custombaseurl/login/

https://github.com/codercom/code-server/blob/c3a38e3fea8a28afa4017cf6c45ba12e82ff1feb/packages/server/src/server.ts#L233-L247

au5ton avatar Apr 18 '19 21:04 au5ton

@yamajik Thank you for the PR to add this feature. Any documentation on how we utilize this? Looking at your code it seems like you are fixing up the URLs? So if we have a server running behind a proxy pointing at something like http:///patrickstjohn it would strip off patrickstjohn and things would work as if you were going to / directly?

@patrickstjohn http:///patrickstjohn Correct url?

In my case, I wanne run behind url http://example.com/some/path/to/code/server.

First, run code server on http://localhost:8443 Then, proxy all requrests(both http, https, ws, wss) from http://example.com/some/path/to/code/server to http://localhost:8443 (maybe by nginx)

In my pr, fixed all incorrect frontend urls I found. I should miss some.

majikxu avatar Apr 19 '19 16:04 majikxu

Index page is redirecting http://hostname/custombaseurl/ to http://hostname/login/ when it should be http://hostname/custombaseurl/login/

code-server/packages/server/src/server.ts

Lines 233 to 247 in c3a38e3

// If not authenticated, redirect to the login page. app.get("/", (req, res, next) => { if (!isAuthed(req)) { return redirect(req, res, "login"); } next(); });

// If already authenticated, redirect back to the root. app.get("/login", (req, res, next) => { if (isAuthed(req)) { return redirect(req, res, "", "login"); } next(); });

@au5ton Yelp. Miss one.

This is a wrong server url. Using relative path or adding a prefix path config both fix this. I prefer adding a prefix path config which may cause troubles in development.

Or u can run behind a reverse proxy server and do not mind it.

majikxu avatar Apr 19 '19 16:04 majikxu