René's URL Explorer Experiment


Title: Fix CSP behind reverse proxy · Issue #4476 · coder/code-server · GitHub

Open Graph Title: Fix CSP behind reverse proxy · Issue #4476 · coder/code-server

X Title: Fix CSP behind reverse proxy · Issue #4476 · coder/code-server

Description: 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...

Open Graph Description: 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...

X Description: 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 spec...

Opengraph URL: https://github.com/coder/code-server/issues/4476

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Fix CSP behind reverse proxy","articleBody":"## What's the problem I'm solving?\r\n\r\nWith the [latest changes](https://github.com/cdr/code-server/pull/4414) 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](https://github.com/cdr/vscode/blob/code-server-v2/src/vs/workbench/browser/client.ts#L125).\r\n\r\nWhen using a reverse proxy (i.e. [Caddy](https://caddyserver.com/)/[NGINX](https://nginx.org/en/)), the update endpoint is incorrect because it has the wrong base path and protocol.\r\n\r\n## What are some ways to go about it?\r\n\r\nThe 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.\r\n\r\n## How will things change/what is the need for maintenance?\r\n\r\nI 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.\r\n\r\nI 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).\r\n\r\n## How to reproduce\r\n\r\nAsher outlined steps below to reproduce this issue locally. To do so, follow these steps:\r\n1. install [Caddy](https://caddyserver.com/) (`brew install caddy`)\r\n2. start code-server locally with `yarn watch`\r\n3. serve it at as base path like `/code` with Caddy\r\n```Caddyfile\r\nhttp://localhost:8082/code/* {\r\n\turi strip_prefix /code\r\n\treverse_proxy 127.0.0.1:8080\r\n}\r\n```\r\n4. navigate to [http://localhost:8082/code/](http://localhost:8082/code/) (trailing slash is important!) \r\n5. observe the update endpoint error in the browser console OR see the Request URL in the network tab (look for a request to `http://localhost:8082/update/check`)\r\n```javascript\r\nContent Security Policy: The page’s settings blocked the loading of a resource at http://localhost:8080/update/check (“connect-src”).\r\n```\r\n\r\n### Expected\r\n\r\nIt makes a request to the correct URL: `http://localhost:8082/code/update/check`\r\n\r\n### Actual \r\n\r\nIt makes a request to the wrong URL: `http://localhost:8082/update/check` (missing `/code`)\r\n![image](https://user-images.githubusercontent.com/3806031/142269851-79947380-fe66-4234-93a0-91f0b2984992.png)\r\n\r\n### Investigation Notes\r\n\r\nBased on what I can tell, this is the line we need to change:\r\n```typescript\r\nreturn new URL(path.join('/', pathPrefix, pathname), remoteAuthority);\r\n```\r\nNotice 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.","author":{"url":"https://github.com/jsjoeio","@type":"Person","name":"jsjoeio"},"datePublished":"2021-11-10T18:18:26Z","url":"https://github.com/coder/code-server/issues/4476"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:b9ccd5f6-4d78-f5c7-b659-da54871fd577
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB04C:2C69FC:C704A5:109A8BC:6B01C9BE
html-safe-noncee6ce176daf1711c5304726d84d4a5d26629384c11d5662142c5669d5de18597b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMDRDOjJDNjlGQzpDNzA0QTU6MTA5QThCQzo2QjAxQzlCRSIsInZpc2l0b3JfaWQiOiIxODk3NDM2NjgyOTMzODg3MzQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac36054d6859d85962dc8213fc6efcbfb2cf006e57e8d9504591652d3932f6d6f0
hovercard-subject-tagissue:1050158317
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/code-server/4476/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bcbc4aa9a295c3502a625c2ab97e2b6b4561816a89710161d88f8240670acf85/coder/code-server/issues/4476
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bcbc4aa9a295c3502a625c2ab97e2b6b4561816a89710161d88f8240670acf85/coder/code-server/issues/4476
og:image:altWhat'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...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejsjoeio
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/coder/code-server git https://github.com/coder/code-server.git
octolytics-dimension-user_id95932066
octolytics-dimension-user_logincoder
octolytics-dimension-repository_id172953845
octolytics-dimension-repository_nwocoder/code-server
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id172953845
octolytics-dimension-repository_network_root_nwocoder/code-server
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/coder/code-server/issues/4476#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcode-server%2Fissues%2F4476
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcoder%2Fcode-server%2Fissues%2F4476
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=coder%2Fcode-server
Reloadhttps://github.com/coder/code-server/issues/4476
Reloadhttps://github.com/coder/code-server/issues/4476
Reloadhttps://github.com/coder/code-server/issues/4476
coderhttps://github.com/coder
code-serverhttps://github.com/coder/code-server
Codehttps://github.com/coder/code-server
Issues147 (147)https://github.com/coder/code-server/issues
Pull requests17 (17)https://github.com/coder/code-server/pulls
Discussionshttps://github.com/coder/code-server/discussions
Actionshttps://github.com/coder/code-server/actions
Projectshttps://github.com/coder/code-server/projects
Security and quality3 (3)https://github.com/coder/code-server/security
Insightshttps://github.com/coder/code-server/insights
https://github.com/coder/code-server
New issuehttps://github.com/login?return_to=https://github.com/coder/code-server/issues/4476
New issuehttps://github.com/login?return_to=https://github.com/coder/code-server/issues/4476
Fix CSP behind reverse proxyhttps://github.com/coder/code-server/issues/4476#top
https://github.com/jsjoeio
bugSomething isn't workinghttps://github.com/coder/code-server/issues?q=state%3Aopen%20label%3A%22bug%22
4.0.0 - pre-releasehttps://github.com/coder/code-server/milestone/32
https://github.com/jsjoeio
jsjoeiohttps://github.com/jsjoeio
on Nov 10, 2021https://github.com/coder/code-server/issues/4476#issue-1050158317
latest changeshttps://github.com/cdr/code-server/pull/4414
herehttps://github.com/cdr/vscode/blob/code-server-v2/src/vs/workbench/browser/client.ts#L125
Caddyhttps://caddyserver.com/
NGINXhttps://nginx.org/en/
Caddyhttps://caddyserver.com/
http://localhost:8082/code/http://localhost:8082/code/
https://user-images.githubusercontent.com/3806031/142269851-79947380-fe66-4234-93a0-91f0b2984992.png
jsjoeiohttps://github.com/jsjoeio
bugSomething isn't workinghttps://github.com/coder/code-server/issues?q=state%3Aopen%20label%3A%22bug%22
on Nov 10, 2021https://github.com/coder/code-server/issues/4476#event-5599076848
jsjoeiohttps://github.com/jsjoeio
3.12.1 - improve release processhttps://github.com/coder/code-server/milestone/30
on Nov 10, 2021https://github.com/coder/code-server/issues/4476#event-5599076862
https://github.com/code-asher
code-asherhttps://github.com/code-asher
on Nov 10, 2021https://github.com/coder/code-server/issues/4476#issuecomment-965698634
jsjoeiohttps://github.com/jsjoeio
3.12.1 - improve release processhttps://github.com/coder/code-server/milestone/30
4.0.0https://github.com/coder/code-server/milestone/32
on Nov 10, 2021https://github.com/coder/code-server/issues/4476#event-5599894225
code-asherhttps://github.com/code-asher
on Nov 10, 2021https://github.com/coder/code-server/issues/4476#event-5600490064
https://github.com/code-asher
code-asherhttps://github.com/code-asher
on Nov 12, 2021https://github.com/coder/code-server/issues/4476#issuecomment-967499217
code-asherhttps://github.com/code-asher
on Nov 12, 2021https://github.com/coder/code-server/issues/4476#event-5611854774
code-asherhttps://github.com/code-asher
on Nov 12, 2021https://github.com/coder/code-server/issues/4476#event-5611854954
code-asherhttps://github.com/code-asher
on Nov 12, 2021https://github.com/coder/code-server/issues/4476#event-5611856022
https://github.com/jsjoeio
jsjoeiohttps://github.com/jsjoeio
on Nov 16, 2021https://github.com/coder/code-server/issues/4476#issuecomment-970793371
@code-asherhttps://github.com/code-asher
https://github.com/jsjoeio
jsjoeiohttps://github.com/jsjoeio
on Nov 17, 2021https://github.com/coder/code-server/issues/4476#issuecomment-971716523
jsjoeiohttps://github.com/jsjoeio
on Nov 17, 2021https://github.com/coder/code-server/issues/4476#event-5634022627
https://github.com/jsjoeio
jsjoeiohttps://github.com/jsjoeio
on Nov 22, 2021https://github.com/coder/code-server/issues/4476#issuecomment-975855165
coder/vscode#17https://github.com/coder/vscode/pull/17
jsjoeiohttps://github.com/jsjoeio
completedhttps://github.com/coder/code-server/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 22, 2021https://github.com/coder/code-server/issues/4476#event-5656278339
Sign up for freehttps://github.com/signup?return_to=https://github.com/coder/code-server/issues/4476
Sign in to commenthttps://github.com/login?return_to=https://github.com/coder/code-server/issues/4476
jsjoeiohttps://github.com/jsjoeio
bugSomething isn't workinghttps://github.com/coder/code-server/issues?q=state%3Aopen%20label%3A%22bug%22
4.0.0 - pre-releasehttps://github.com/coder/code-server/milestone/32
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.