Skip to content
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

[Bug]: error Forbidden HttpError: Forbidden #6064

Closed
4 tasks done
Bubbler-4 opened this issue Mar 11, 2023 · 27 comments · Fixed by #6319
Closed
4 tasks done

[Bug]: error Forbidden HttpError: Forbidden #6064

Bubbler-4 opened this issue Mar 11, 2023 · 27 comments · Fixed by #6319
Labels
bug Something isn't working triage This issue needs to be triaged by a maintainer

Comments

@Bubbler-4
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Chrome
  • Local OS: Windows
  • Remote OS: Ubuntu 18.04
  • Remote Architecture: amd64
  • code-server --version: 4.10.1-rc1 and 4.10.1

Steps to Reproduce

  1. Install code-server from .deb package
  2. Run code-server --bind-addr 0.0.0.0:8080
  3. Open the page

Expected

Remote:

[2023-03-11T05:58:43.359Z] info  code-server 4.10.0 ac1fba8bde0c3f29bf6bc27d3d7d75cb2390a7c2
[2023-03-11T05:58:43.361Z] info  Using user-data-dir ~/.local/share/code-server
[2023-03-11T05:58:43.458Z] info  Using config file ~/.config/code-server/config.yaml
[2023-03-11T05:58:43.458Z] info  HTTP server listening on http://0.0.0.0:8080/
[2023-03-11T05:58:43.459Z] info    - Authentication is enabled
[2023-03-11T05:58:43.459Z] info      - Using password from ~/.config/code-server/config.yaml
[2023-03-11T05:58:43.459Z] info    - Not serving HTTPS
[05:58:51]




[05:58:51] Extension host agent started.
[05:58:52] Started initializing default profile extensions in extensions installation folder. file:///root/.local/share/code-server/extensions
[05:58:52] Completed initializing default profile extensions in extensions installation folder. file:///root/.local/share/code-server/extensions
[05:58:57] No ptyHost heartbeat after 6 seconds
[05:59:08] [172.17.0.1][5925d035][ManagementConnection] New connection established.
[05:59:18] [172.17.0.1][a31737ae][ExtensionHostConnection] New connection established.
[05:59:18] [172.17.0.1][a31737ae][ExtensionHostConnection] <4008> Launched Extension Host Process.

Local:

code-server-ok

Actual

Remote:

[2023-03-11T06:01:52.558Z] info  code-server 4.10.1-rc.1 d477972c68fc8c8e8d610aa7287db87ba90e55c7
[2023-03-11T06:01:52.560Z] info  Using user-data-dir ~/.local/share/code-server
[2023-03-11T06:01:52.658Z] info  Using config file ~/.config/code-server/config.yaml
[2023-03-11T06:01:52.658Z] info  HTTP server listening on http://0.0.0.0:8080/
[2023-03-11T06:01:52.659Z] info    - Authentication is enabled
[2023-03-11T06:01:52.659Z] info      - Using password from ~/.config/code-server/config.yaml
[2023-03-11T06:01:52.659Z] info    - Not serving HTTPS
[2023-03-11T06:01:53.450Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
[2023-03-11T06:01:54.389Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
[06:02:09]




[06:02:09] Extension host agent started.
[2023-03-11T06:02:13.870Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:13.961Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:14.055Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:14.143Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:14.239Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:14.557Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:14.652Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:14.859Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:15.055Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[2023-03-11T06:02:15.154Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)
[06:02:15] No ptyHost heartbeat after 6 seconds
File not found: /usr/lib/code-server/lib/vscode/extensions/git-base/dist/browser/extension.js
File not found: /usr/lib/code-server/lib/vscode/extensions/emmet/dist/browser/emmetBrowserMain.js
File not found: /usr/lib/code-server/lib/vscode/extensions/merge-conflict/dist/browser/mergeConflictMain.js

Local:

code-server-error

Logs

No response

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

No response

@Bubbler-4 Bubbler-4 added bug Something isn't working triage This issue needs to be triaged by a maintainer labels Mar 11, 2023
@JiaY-shi
Copy link

same issue

@code-asher
Copy link
Member

Do you use a reverse proxy? If so you may need to set the host header. #6052

@lanrat
Copy link

lanrat commented Mar 20, 2023

I'm also having this exact issue.
The issue started happening after upgrading to 4.10.1 over 4.10.0.

I am using nginx as a reverse proxy and I looked into #6052, but after much debugging I can confirm that I have the Host header set correctly to $host, but I'm still seeing this issue.

Downgrading back to 4.10.0 fixes the issue for now.

@code-asher
Copy link
Member

code-asher commented Mar 20, 2023

Do you see a "no host headers found" warning in code-server's output? If yes then the host is not making it to code-server somehow.

If no then probably one of the following:

  1. The host does not match the origin the browser is sending. Could possibly check the browser console network tab to see what the browser is sending for the origin and whether that matches the host.
  2. We first check the host in forwarded and x-forwarded-host so if those headers are being set might need to double-check them.
  3. The origin is not a valid URL (we block requests when unable to parse the origin).

Edit: when the check fails I wonder if we should output what we got for all those headers to help debugging.

@lanrat
Copy link

lanrat commented Mar 20, 2023

My logs code-server logs are identical to the ones in the first comment's logs.

  1. I have verified that the browser is sending the correct host header. In fact, if it was not my reverse proxy would not respond.
  2. The X-Forwarded-Host header is also sent corectly.
  3. The origin is a valid SSL Host. Nginx is acting as a reverse proxy exposing code-server with a valid SSL certificate on its own domain name.

Knowing what is causing the error other than error Forbidden HttpError: Forbidden would be helpful. Looking at the browser console logs, I also see that some static JS resources are also getting a 404 from code-server, but I'm not sure if this is related. These same resources do not seem to be used on 4.10.0.

@code-asher
Copy link
Member

I believe the 404s are unrelated but worth looking into separately. I have seen them as well but am unaware of the cause as of yet.

This particular forbidden error can only occur if this function returns false:

export function authenticateOrigin(req: express.Request): boolean {
// A missing origin probably means the source is non-browser. Not sure we
// have a use case for this but let it through.
const originRaw = getFirstHeader(req, "origin")
if (!originRaw) {
return true
}
let origin: string
try {
origin = new URL(originRaw).host.trim().toLowerCase()
} catch (error) {
return false // Malformed URL.
}
// Honor Forwarded if present.
const forwardedRaw = getFirstHeader(req, "forwarded")
if (forwardedRaw) {
const parts = forwardedRaw.split(/[;,]/)
for (let i = 0; i < parts.length; ++i) {
const [key, value] = splitOnFirstEquals(parts[i])
if (key.trim().toLowerCase() === "host" && value) {
return origin === value.trim().toLowerCase()
}
}
}
// Honor X-Forwarded-Host if present.
const xHost = getFirstHeader(req, "x-forwarded-host")
if (xHost) {
return origin === xHost.trim().toLowerCase()
}
// A missing host likely means the reverse proxy has not been configured to
// forward the host which means we cannot perform the check. Emit a warning
// so an admin can fix the issue.
const host = getFirstHeader(req, "host")
if (!host) {
logger.warn(`no host headers found; blocking request to ${req.originalUrl}`)
return false
}
return origin === host.trim().toLowerCase()
}

There very well may be a bug here but I am struggling to find what it could be. I suppose one other theory is that the headers are being sent multiple times (we only check the first one) but that seems unlikely.

I will add some debug logs for the next version.

@john-liuqiming
Copy link

I also use a nginx as reverse proxy for ssl access and have the same issue. I fixed it by adding "proxy_set_header X-Forwarded-Host $http_host;" to my nginx config.

@JiaY-shi
Copy link

I also use a nginx as reverse proxy for ssl access and have the same issue. I fixed it by adding "proxy_set_header X-Forwarded-Host $http_host;" to my nginx config.

I also fixed it by adding this configuration.

@AquaRelliux
Copy link

I also have this error and it was not fixed by adding the configuration that was suggested above. Rolling back to 4.10.0 fixed it though

@covert8
Copy link

covert8 commented Apr 13, 2023

We are hosting code-server on our hpc cluster using https://github.com/OSC/ondemand and have limited control over our reverse proxy settings. Could there perhaps be an override or a variable giving the expected X-Forwarded-Host?

GET /_static/out/browser/serviceWorker.js HTTP/1.1
Host: k28i16.tier2.hpc.kuleuven.be:8080
X-Forwarded-Host: icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be, icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Server: 96244511ce3d, icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be
X-Forwarded-Escaped-Uri: %2f_static%2fout%2fbrowser%2fserviceWorker.js
Connection: close

@code-asher
Copy link
Member

code-asher commented Apr 13, 2023 via email

@covert8
Copy link

covert8 commented Apr 17, 2023

The allowed-hosts would suffice.

But concerning you point about the X-forwarded-Host header, it is correct/what the user sees in their url field. I'll check on what branch the check fails.

https://icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be/rnode/k28i16.tier2.hpc.kuleuven.be/8080/ is the url with X-Forwarded-Host: icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be set

@code-asher
Copy link
Member

Interesting...definitely odd, in that case presumably the browser sets origin to https://icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be/rnode/k28i16.tier2.hpc.kuleuven.be and the check should pass since the hosts match. 🤔

@Nuetron06
Copy link

I can also confirm that the recent update in the nginx ssl proxy to add the proxy set header has not solved my problem. I am getting the exact logs the OP has.

Tuxprogrammer added a commit to Tuxprogrammer/kubeflow that referenced this issue Apr 24, 2023
@code-asher
Copy link
Member

code-asher commented Apr 24, 2023 via email

@code-asher
Copy link
Member

code-asher commented Apr 24, 2023

Might need to use $http_host instead: #6166

SunsetMkt added a commit to A-SunsetMkt-Forks/deploy-code-server that referenced this issue Apr 27, 2023
@Nuetron06
Copy link

Nuetron06 commented May 11, 2023

Sorry about taking so long to get back with you.
Here's the log when the addon starts, using Debug:

s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting
-----------------------------------------------------------
 Add-on: Studio Code Server
 Fully featured Visual Studio Code (VSCode) experience integrated in the Home Assistant frontend.
-----------------------------------------------------------
 Add-on version: 5.5.7
 You are running the latest version of this add-on.
 System: Debian GNU/Linux 11 (bullseye)  (amd64 / qemux86-64)
 Home Assistant Core: 2023.5.2
 Home Assistant Supervisor: 2023.04.1
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-timezone: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
[14:45:53] INFO: Configuring timezone (America/Chicago)...
s6-rc: info: service base-addon-timezone successfully started
Log level is set to DEBUG
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-user: starting
s6-rc: info: service init-mysql: starting
s6-rc: info: service init-mosquitto: starting
s6-rc: info: service init-code-server: starting
s6-rc: info: service init-code-server successfully started
s6-rc: info: service init-user successfully started
s6-rc: info: service code-server: starting
[14:45:53] DEBUG: Requested API resource: http://supervisor/services/mqtt
[14:45:53] DEBUG: Request method: GET
[14:45:53] DEBUG: Request data: {}
[14:45:53] DEBUG: API HTTP Response code: 200
[14:45:53] DEBUG: API Response: {"result": "ok", "data": {"host": "core-mosquitto", "port": 1883, "ssl": false, "protocol": "3.1.1", "username": "addons", "password": "<redacted>", "addon": "core_mosquitto"}}
s6-rc: info: service code-server successfully started
[14:45:53] DEBUG: Requested API resource: http://supervisor/services/mysql
[14:45:53] DEBUG: Request method: GET
[14:45:53] DEBUG: Request data: {}
[14:45:53] INFO: Starting code-server...
[14:45:53] DEBUG: API HTTP Response code: 200
[14:45:53] DEBUG: API Response: {"result": "ok", "data": {"host": "core-mariadb", "port": 3306, "username": "service", "password": "<redacted>", "addon": "core_mariadb"}}
s6-rc: info: service init-mosquitto successfully started
s6-rc: info: service init-mysql successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[2023-05-11T19:45:54.099Z] info  Wrote default config file to ~/.config/code-server/config.yaml
[2023-05-11T19:45:54.470Z] info  code-server 4.11.0 85e083580dec27ef19827ff42d3c9257d56ea7e3
[2023-05-11T19:45:54.470Z] info  Using user-data-dir /data/vscode
[2023-05-11T19:45:54.481Z] info  Using config file ~/.config/code-server/config.yaml
[2023-05-11T19:45:54.481Z] info  HTTP server listening on http://0.0.0.0:1337/
[2023-05-11T19:45:54.481Z] info    - Authentication is disabled
[2023-05-11T19:45:54.481Z] info    - Not serving HTTPS

This remains as-is until I try to access the GUI:

[14:48:19] 
[14:48:19] Extension host agent started.
[2023-05-11T19:48:20.590Z] error Forbidden HttpError: Forbidden
    at ensureOrigin (/usr/local/lib/code-server/out/node/http.js:288:15)
    at wrapped (/usr/local/lib/code-server/out/node/wsRouter.js:64:24)
    at Layer.handle [as handle_request] (/usr/local/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at next (/usr/local/lib/code-server/node_modules/router/lib/route.js:144:13)
    at Route.dispatch (/usr/local/lib/code-server/node_modules/router/lib/route.js:109:3)
    at handle (/usr/local/lib/code-server/node_modules/router/index.js:515:11)
    at Layer.handle [as handle_request] (/usr/local/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at /usr/local/lib/code-server/node_modules/router/index.js:291:22
    at param (/usr/local/lib/code-server/node_modules/router/index.js:368:14)
    at param (/usr/local/lib/code-server/node_modules/router/index.js:379:14)
    at Function.process_params (/usr/local/lib/code-server/node_modules/router/index.js:424:3)
    at next (/usr/local/lib/code-server/node_modules/router/index.js:285:10)
    at Function.handle (/usr/local/lib/code-server/node_modules/router/index.js:184:3)
    at router (/usr/local/lib/code-server/node_modules/router/index.js:59:12)
    at Layer.handle [as handle_request] (/usr/local/lib/code-server/node_modules/router/lib/layer.js:102:15)
    at trim_prefix (/usr/local/lib/code-server/node_modules/router/index.js:330:13)
    at /usr/local/lib/code-server/node_modules/router/index.js:294:7
    at Function.process_params (/usr/local/lib/code-server/node_modules/router/index.js:349:12)
    at Immediate.next (/usr/local/lib/code-server/node_modules/router/index.js:285:10)
    at Immediate.<anonymous> (/usr/local/lib/code-server/node_modules/router/index.js:671:15)
    at processImmediate (node:internal/timers:468:21)

The above is repeated every few seconds as long as I'm leaving the GUI page trying to load, which eventually gives me the unexpected error:

image

@code-asher
Copy link
Member

code-asher commented May 11, 2023

@Nuetron06 is code-server actually getting the debug level set and is this 4.12.0? You should see this preceding the forbidden line:

[2023-05-11T21:20:21.080Z] debug host "localhost:8080" does not match origin "domain.example"; blocking request to /
[2023-05-11T21:20:21.082Z] error Forbidden HttpError: Forbidden

@Nuetron06
Copy link

Nuetron06 commented May 11, 2023

@code-asher Yep. The DEBUG: lines weren't there before I enabled it in the "unused" options on the config page of HomeAssistant. I confirmed it even switches to TRACE when I set it, and that line does not show. I've got SCS v5.57.

I do have Nginx SSL Proxy Manager set with a custom external port (843 instead of 8443), if that helps.

I also have esphome installed and had to add a proxy set header line for location /ingress/api for ESPhome. I've confirmed removing this line has no effect on it.

EDIT: Hold a sec, checking the HA addon that is wrapping SCS.

EDIT2: from the changelog:
Update keesschollaart81/vscode-home-assistant to v1.35.1 @renovate (#606)

EDIT3:
Looks like the latest in the HA Addon is 4.11.0

@code-asher
Copy link
Member

code-asher commented May 11, 2023

I do see the DEBUG lines but none from code-server itself so not sure if that is getting propagated down to code-server. You should see that line that tells you why it rejected the request so if you are not seeing it likely code-server's debug flag is not getting set.

Do you use $host or $http_host for the host header in your NGINX config? Might need $http_host, could be trying to match domain instead of domain:8443 since $host drops the port.

@gergelymark
Copy link

We are hosting code-server on our hpc cluster using https://github.com/OSC/ondemand and have limited control over our reverse proxy settings. Could there perhaps be an override or a variable giving the expected X-Forwarded-Host?

GET /_static/out/browser/serviceWorker.js HTTP/1.1
Host: k28i16.tier2.hpc.kuleuven.be:8080
X-Forwarded-Host: icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be, icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be
X-Forwarded-Port: 443
X-Forwarded-Proto: https
X-Forwarded-Server: 96244511ce3d, icts-q-hpc-openondemand.cloud.q.icts.kuleuven.be
X-Forwarded-Escaped-Uri: %2f_static%2fout%2fbrowser%2fserviceWorker.js
Connection: close

In my setting the very same thing happens. Using the debug flag I see the following error message:
debug host "foo.bar.com, foo.bar.com" does not match origin "foo.bar.com"; blocking request to ....

So what I see is that the x-forwarded-host is actually set, and as far as I understand set correctly (host might contain comma separated list of hostnames - again as far as I understand). So it does seem a bug, might be a specific case, but the hostnames sent and hostname expected are actually the same. In this case the string equality check won't work, the hostname set might be an array of hostnames.

Can you please verify?
Thanks in advance :)

@code-asher
Copy link
Member

Ahh I should have noticed that when y'all first posted the headers, sorry.

Yeah X-Forwarded-Host is used verbatim, looks like we need to split on commas! Opened an issue: #6215

@code-asher
Copy link
Member

code-asher commented May 16, 2023

Er wait I was looking at the wrong documentation, I was looking at X-Forwarded-For. Are multiple hosts valid syntax for X-Forwarded-Host? Looks like it is supposed to contain a single host.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host

Edit: still not sure if it is technically valid but seems little harm in supporting it plus the header is non-standard anyway.

@gergelymark
Copy link

gergelymark commented May 16, 2023 via email

@code-asher
Copy link
Member

Added support for commas, will come out in the next version tomorrow or so.

@code-asher
Copy link
Member

4.13.0 is out and supports X-Forwarded-Host with comma-separated hosts (it will use the first one).

@xzfxzrs
Copy link

xzfxzrs commented Jul 7, 2023

today i met the same problem too in version 4.14.1

the point is that i have no way to control the reverse proxy.

so i just have a monkey fix in the file code-server-4.14.1-linux-amd64/out/node/http.js

function getHost(req) {
    // Honor Forwarded if present.
    //  ============== fix lines =============
    if(true) {
        return "you domain";
    }
    // =============== fix line end ==============
    const forwardedRaw = getFirstHeader(req, "forwarded");
    if (forwardedRaw) {
        const parts = forwardedRaw.split(/[;,]/);
        ....

it is not in security but just work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage This issue needs to be triaged by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants