I installed the code server from GitHub/OSC to OOD. But, it does not work.
When launching the code server from OOD, I got a 404 Not Found page. This is because the code server login site redirects a broken URL with duplicated server/port in it.
The broken URL is http://DOMAIN/rnode/HOST/PORT/rnode/HOST/PORT/login
But the right URL must be http://DOMAIN/rnode/HOST/PORT/login
When I go to the right URL, the code server works. This issue may be the same as #882.
The Pull Request made in #882 seems to have been merged into the OOD master branch. But this error continues in my environment.
I use OOD v2.0.23 and tried the code server some versions (v3.3.1, v3.4.1, and v3.9.3, v3.10.2). The reason I’ve tried multiple versions is that this issue may depend on the version of the code server. But all versions got the same error.
When accessing this with https instead of wss then I see that it gets redirected to the double-nesting URL as previously. So… maybe the stripping of the prefix of rnode is not as complete as one would hope?
So it appears that this again redirects to ./ which then causes problem.
I can confirm that v3.12.0 works with login disabled but has a similar problem when enabling password. Even when going to the /login URL, it tries to redirect to the twice-nested URL.
Looking into this a bit further. The logs of the code-server say
[2022-04-08T11:02:32.341Z] debug redirecting from /? to ./login
[2022-04-08T11:03:18.773Z] debug redirecting from /? to ./login
[2022-04-08T11:03:26.496Z] debug redirecting from /? to ./login
So I assume that we’re adding an unnecessary /rnode prefix
edit2: This looks similar to the following
So, what does the regex “^([^/]+//[^/]+)|(?=/)” mean? My interpretation is that if the path does not start with a slash / but contains a double-slash // and is followed by one or more non-slash characters then then everything up to but excluding the next slash / is matched and replaced with /rnode/.... If this is not the case but the string contains a slash / then we prepend /node....
What happens in the case of redirecting to ./login (If my assumptions above are correct)? Well, we would prepend /rnode/... and we end up with adding too much.
This makes it match an string containing a slash that is not ./… or so. At least the nested redirect does not happen BUT I get to see the login form and cannot get behidn it.
Same issue with the latest code-server release (4.5.0). Devs over there state that everything should be using the relative path but they have been fixing constant bugs due to things not using relative paths correctly.
Not sure if this is an OOD issue or a code-server issue. Probably needs review from one of the OOD devs to determine.
Sorry for the troubles people have had. I was able to look at code-server 4.5 and address the issue there for the broken login. I’ve got a PR in to fix that specific version, but reading through this thread I would wonder if other versions can be fixed using the same logic.
Essentially we needed to alter the view to use a post with the password but only for certain versions of code-server. This meant we needed the view to know a bit about the context which was done using a conn_params to communicate this information between the pieces of the bc_osc_codeserver app.
I have similar setup in our code-server app (NMSU_HPC / ood_bc_codeserver · GitLab) that I have been sharing in a few other posts. It works for my site with RHEL 8, the latest OOD stable, and the official ansible ood install role. However, for others on RHEL 7, or Ubuntu, it has the same redirect issues with rnode is seen previously.
Thanks for the context! I have another issue on my plate currently I need to prioritize, but will circle back around to investigating this with those specific OSs to see why that is happening.
It looks like the apache config generated on rhel 8 with Ondemand 2.0.28-1.el8 is a bit different and solved the redirect issue for my site after having migrated from CentOS 7 to RHEL 8.
If you look closely it looks like the regex in Header edit Location has been adjusted to account for ./ locations. That or the 2 referenced lua scripts are different in RHEL 8 and somehow fixing the issue.
Looking through our git log, the relative path support is an update to 2.0.28 itself and not OS dependent. I know I fixed relative paths for 2.1 and we had to backport it for Ubuntu support (for some reason Debian’s apache2 package needed it).