-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[Bug]: proxy by nginx websocket origin check error #6161
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
I fix it by modify nginx config proxy_set_header 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-Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme; Modified proxy_set_header 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-Host $host; <=== remove port
proxy_set_header X-Forwarded-Proto $scheme; |
Oh interesting! We should make special exceptions for 443 and 80. #6166 |
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. |
try nginx config as follows: location ~ ${your frontend url pattern} {
# add it if your url is dynamic
resolver {your DNS server}
# trick here, consult here for Nginx official doc
proxy_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 host
proxy_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:
|
Is there an existing issue for this?
OS/Web Information
code-server --version
: 4.12.0Steps to Reproduce
Expected
.
Actual
websocket connect error code 1006
Logs
debug host "ide.wsc.ink:443" does not match origin "ide.wsc.ink";
Screenshot/Video
No response
Does this issue happen in VS Code or GitHub Codespaces?
Are you accessing code-server over HTTPS?
Notes
No response
The text was updated successfully, but these errors were encountered: