Thanks for this, I was a few versions behind on code-server, and was getting this error. I had none of these set in my old nginx file, and adding them solved the issue for me.
location~ ${your frontend url pattern}{ # add it if your url is dynamicresolver{your DNS server} # trick here, consult here for Nginx official docproxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade; # trick here, if absent, the server will block the websocket request if the origin is NOT equal to the hostproxy_set_header Origin http://${your backend host}/;proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_set_header Accept-Encoding gzip;proxy_cookie_domain ${your backend host} ${your frontend host};proxy_pass ${your backend url pattern};}
config above working for me. my scene:
code-server: 4.18.0, running in an container of Kubernetes
nginx:1.9.7, running in an container of another Kubernetes.
Activity
502647092 commented on Apr 23, 2023
I fix it by modify nginx config
Origin Config
Modified
code-asher commented on Apr 24, 2023
Oh interesting! We should make special exceptions for 443 and 80. #6166
kylefmohr commented on Jun 28, 2023
@502647092
Thanks for this, I was a few versions behind on code-server, and was getting this error. I had none of these set in my old nginx file, and adding them solved the issue for me.
mashroomxl commented on Nov 12, 2023
try nginx config as follows:
config above working for me. my scene: