websocket 1006 error
danktankk opened this issue · 7 comments
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
when I log into codeserver i am greeted with a websocket 1006 error
Expected Behavior
no webnsocket error
Steps To Reproduce
log into the webUI and there is the error
Environment
- OS:UNRAID
- How docker service was installed:
CPU architecture
x86-64
Docker creation
its unraid.... i didnt create the container in any traditional sense
Container logs
04/13/2023 9:19:18 PM
[2023-04-14T01:19:18.886Z] error Forbidden HttpError: Forbidden
04/13/2023 9:19:18 PM
at ensureOrigin (/app/code-server/out/node/http.js:288:15)
04/13/2023 9:19:18 PM
at wrapped (/app/code-server/out/node/wsRouter.js:64:24)
04/13/2023 9:19:18 PM
at Layer.handle [as handle_request] (/app/code-server/node_modules/router/lib/layer.js:102:15)
04/13/2023 9:19:18 PM
at next (/app/code-server/node_modules/router/lib/route.js:144:13)
04/13/2023 9:19:18 PM
at Route.dispatch (/app/code-server/node_modules/router/lib/route.js:109:3)
04/13/2023 9:19:18 PM
at handle (/app/code-server/node_modules/router/index.js:515:11)
04/13/2023 9:19:18 PM
at Layer.handle [as handle_request] (/app/code-server/node_modules/router/lib/layer.js:102:15)
04/13/2023 9:19:18 PM
at /app/code-server/node_modules/router/index.js:291:22
04/13/2023 9:19:18 PM
at param (/app/code-server/node_modules/router/index.js:368:14)
04/13/2023 9:19:18 PM
at param (/app/code-server/node_modules/router/index.js:379:14)
04/13/2023 9:19:18 PM
at Function.process_params (/app/code-server/node_modules/router/index.js:424:3)
04/13/2023 9:19:18 PM
at next (/app/code-server/node_modules/router/index.js:285:10)
04/13/2023 9:19:18 PM
at Function.handle (/app/code-server/node_modules/router/index.js:184:3)
04/13/2023 9:19:18 PM
at router (/app/code-server/node_modules/router/index.js:59:12)
04/13/2023 9:19:18 PM
at Layer.handle [as handle_request] (/app/code-server/node_modules/router/lib/layer.js:102:15)
04/13/2023 9:19:18 PM
at trim_prefix (/app/code-server/node_modules/router/index.js:330:13)
04/13/2023 9:19:18 PM
at /app/code-server/node_modules/router/index.js:294:7
04/13/2023 9:19:18 PM
at Function.process_params (/app/code-server/node_modules/router/index.js:349:12)
04/13/2023 9:19:18 PM
at Immediate.next (/app/code-server/node_modules/router/index.js:285:10)
04/13/2023 9:19:18 PM
at Immediate.<anonymous> (/app/code-server/node_modules/router/index.js:671:15)
04/13/2023 9:19:18 PM
at processImmediate (node:internal/timers:468:21)
Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.
Issue is likely your reverse proxy
Issue is likely your reverse proxy
Ill have a look. I haven't changed anything in it in months but I can still see how an update would break things. I have read a lot before posting here regarding certain entries missing, all of which I already have in my proxy.conf file. Its still possible that there is a nother issue. Ill try to install it on another server.
[EDIT]
After installing it on another server and using ip:port on both installs - it is definitel;y something to do with my reverse proxy, but I am not sure where the issue is. some help in where to look would be great. thanks for the tip.
I dont understand what could have changed to where my reverse proxy now doesnt work when it did for about a year.
Looks like this is related to a recent security fix in code-server where it checks the origin against the host on web socket requests (since browsers neglect to do so).
If the origin
is set then it must be a valid URL and the host must match the host
header exactly. http://domain.tld:1234
and domain.tld:1234
or https://domain.tld
and domain.tld
for example.
That means the proxy is either dropping the host or setting it to something that does not match the origin. With something like NGINX this would mean adding proxy_set_header Host $http_host;
.
Also in the latest version of code-server with --log debug
it will tell you what it gets for the origin and host in case that is helpful.
This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.
我使用docker部署的code-server,然后使用docker中的nginx进行ssl的转发,增加了
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
以上三个配置,并且也配置了证书。访问nginx代理 的ssl端口,提示wss 1006
——————————————————————————————————————————————————————
I use the code-server deployed by docker, and then use nginx in docker to forward ssl, adding
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
The above three configurations, and the certificate is also configured. Access the ssl port of the nginx proxy, prompting wss 1006
I managed to fix this by setting up my nginx conf like:
`server {
server_name sub.main.dom;
location / {
proxy_pass http://192.168.xxx.xxx:8443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/sub.main.dom/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/sub.main.dom/privkey.pem;
}`
props to ChatGPT, hope this works for you