FAQ.md: Document --proxy-path-passthrough

And the concerns surrounding it.

Closes #2485
This commit is contained in:
Anmol Sethi 2021-01-11 13:18:07 -05:00
parent f169e3ac66
commit 497b01bffe
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB

View File

@ -15,6 +15,7 @@
- [How do I securely access web services?](#how-do-i-securely-access-web-services) - [How do I securely access web services?](#how-do-i-securely-access-web-services)
- [Sub-paths](#sub-paths) - [Sub-paths](#sub-paths)
- [Sub-domains](#sub-domains) - [Sub-domains](#sub-domains)
- [Why does the code-server proxy strip `/proxy/<port>` from the request path?](#why-does-the-code-server-proxy-strip-proxyport-from-the-request-path)
- [Multi-tenancy](#multi-tenancy) - [Multi-tenancy](#multi-tenancy)
- [Docker in code-server container?](#docker-in-code-server-container) - [Docker in code-server container?](#docker-in-code-server-container)
- [How can I disable telemetry?](#how-can-i-disable-telemetry) - [How can I disable telemetry?](#how-can-i-disable-telemetry)
@ -208,6 +209,36 @@ code-server --proxy-domain <domain>
Now you can browse to `<port>.<domain>`. Note that this uses the host header so Now you can browse to `<port>.<domain>`. Note that this uses the host header so
ensure your reverse proxy forwards that information if you are using one. ensure your reverse proxy forwards that information if you are using one.
## Why does the code-server proxy strip `/proxy/<port>` from the request path?
HTTP servers should strive to use relative URLs to avoid needed to be coupled to the
absolute path at which they are served. This means you must use trailing slashes on all
paths with subpaths. See https://blog.cdivilly.com/2019/02/28/uri-trailing-slashes
This is really the "correct" way things work and why the striping of the base path is the
default. If your application uses relative URLs and does not assume the absolute path at
which it is being served, it will just work no matter what port you decide to serve it off
or if you put it in behind code-server or any other proxy!
However many people prefer the cleaner aesthetic of no trailing slashes. This couples you
to the base path as you cannot use relative redirects correctly anymore. See the above
link.
For users who are ok with this tradeoff, pass `--proxy-path-passthrough` to code-server
and the path will be passed as is.
This is particularly a problem with the `start` script in create-react-app. See
[#2222](https://github.com/cdr/code-server/issues/2222). You will need to inform
create-react-app of the path at which you are serving via `homepage` field in your
`package.json`. e.g. you'd add the following for the default CRA port:
```json
"homepage": "/proxy/3000",
```
Then visit `https://my-code-server-address.io/proxy/3000` to see your app exposed through
code-server!
## Multi-tenancy ## Multi-tenancy
If you want to run multiple code-servers on shared infrastructure, we recommend using virtual If you want to run multiple code-servers on shared infrastructure, we recommend using virtual