-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix basePath #1272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix basePath #1272
Conversation
Edited the message just to reference GH-1237 and allow a merge to auto-close this. |
The base path actually doesn't have anything to do routing incoming
requests. That's the job of a reverse proxy. We use the base path to
redirect from the login page and to set some headers to the root path.
If we made this change then this could break reverse proxies that are
properly configured. For example if someone configured their path to be
`/vs` then all of our `/vs` paths will stop working because the `vs`
gets stripped out.
When receiving a request to `/code/some/path` the reverse proxy should
route that and code-server should receive it as `/some/path`, meaning
the base path is already stripped. So the linked issue most likely has
to do with a misconfigured reverse proxy (or isn't using one at all, in
which case there is no need for the base path in the first place).
Hopefully that makes sense. Maybe we should write a message to stdout
when the `base-path` flag is in use explaining some of this?
|
My understanding about Implementation could be different, but this is the ask of all those issues raised saying base path is not working. Any thoughts?? |
I think all of those applications provide a base path exactly for the
purpose of putting them behind a reverse proxy. Is that not the case?
I'm not clear on what the benefit would be of using a base path without
a reverse proxy. Suppose you host code-server at example.com and then
provide a base path of /vs so it's accessible at example.com/vs. Why not
let it be accessed at example.com and skip the base path entirely?
Nothing can be hosted there anyway since code-server is already there.
Also after this change a reverse proxy working today at example.com/code
would require you to access code-server at example.com/code/code. I
can't think of any implementation that wouldn't have this problem.
Let me know if I'm missing something!
|
@code-asher Let me try to break it down for you. The requirement is, we need to run multiple code-servers behind the proxy for multiple users. Now this can be achieved this by rewriting the URL inside the proxy server. But not all proxy servers support this feature (eg: configurable-http-proxy). if we can run the app in the context or path provided by the |
Ahhh, so this is for proxies that cannot rewrite the URL before passing
it along to code-server. That makes sense.
I'm still not sure how best we can support this scenario without
breaking it for proxies that do support that like I previously
mentioned. We would need to know beforehand whether the proxy was
rewriting the URL or not so we can act appropriately. I'm open to ideas
on this. Maybe a new flag like `--proxy-path`?
|
Or maybe `--rewrite-url`.
|
@code-asher We dont need to do anything extra for proxy's with rewrite capability. It will work out of the box. |
If the base path just so happens not to be any path that code-server
itself used then everything would be fine. That does seem likely, but
it's not something I'd feel comfortable relying on.
For example suppose you hosted code-server at `example.com/vs` with
`--base-path=/vs`.
Then suppose code-server itself has an endpoint at `/vs` and a request
is made to example.com/vs/vs. Without a rewriting proxy the result is
/vs. All is well and the /vs endpoint is served. With rewriting the
result is / and the homepage is served instead.
This could be solved by not passing the base path if you're using a
rewriting proxy, but unfortunately the base path would still be
necessary for redirections and for setting certain headers (like the
base path for service workers).
I'm not sure we'll be able to have consistent rewriting behavior without
first knowing whether the URL has already been rewritten, and the only
way to know that is to be told by the user.
Maybe we could add a boolean flag `--rewrite` which turns on URL
rewriting? When `--base-path` is set we could also output some text
about `--rewrite` to raise awareness.
I'm definitely open to other solutions if there are any.
|
See #1237 |
This PR fixes #1237