-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix CSP behind reverse proxy #4476
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
Comments
To test:
Here is an example using Caddy off localhost:
In my case the resource should be |
Another example, using NGINX behind a dev URL:
Should be |
@code-asher check out |
Caddy file
Browse |
Fixed via coder/vscode#17 |
What's the problem I'm solving?
With the latest changes to use the upstream server in code-server, we're now running into Content-Security-Policy issues with our reverse proxy. The specific code we're talking about lives here.
When using a reverse proxy (i.e. Caddy/NGINX), the update endpoint is incorrect because it has the wrong base path and protocol.
What are some ways to go about it?
The most ideal way to solve this is to use relative endpoints. This way, code-server doesn't care about the base path or protocol. It only knows and uses relative paths.
How will things change/what is the need for maintenance?
I am not sure if there is historical context I may be missing which would explain why we didn't use a relative path from the start (or rather why upstream didn't). Patching this in
vscode
means it's something we'll need to keep an eye on as we continue staying in line with upstream.I can't imagine this introducing any breaking changes but it could potentially break in specific environments if they don't support using relative paths for some reason 🤔 (though none specifically come to mind).
How to reproduce
Asher outlined steps below to reproduce this issue locally. To do so, follow these steps:
brew install caddy
)yarn watch
/code
with Caddyhttp://localhost:8082/update/check
)Expected
It makes a request to the correct URL:
http://localhost:8082/code/update/check
Actual
It makes a request to the wrong URL:

http://localhost:8082/update/check
(missing/code
)Investigation Notes
Based on what I can tell, this is the line we need to change:
Notice the hard-coded
'/'
: that assumes we're always serving from the root but if we're using a reverse proxy and serving from a path like/code
then this doesn't return the correct URL.The text was updated successfully, but these errors were encountered: