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

websocket: request origin not allowed by Upgrader.CheckOrigin #118

Closed
NickM-27 opened this issue Nov 24, 2022 · 10 comments
Closed

websocket: request origin not allowed by Upgrader.CheckOrigin #118

NickM-27 opened this issue Nov 24, 2022 · 10 comments
Labels
question Further information is requested

Comments

@NickM-27
Copy link
Contributor

After updating to rc4 I am getting this error regardless of if api -> origin is set to "*" or "" when it was previously working. I am not sure if this is a go2rtc issue or something that needs to be adapted to

@AlexxIT AlexxIT added the question Further information is requested label Nov 24, 2022
@AlexxIT
Copy link
Owner

AlexxIT commented Nov 24, 2022

api > origin should disable this check. Don't know why it doesn't work. This problem could be happened because wrong port forwarding via docker #28
I have removed dummy fix for this issue because origin settings now exist.

@NickM-27
Copy link
Contributor Author

Interesting, we are using an nginx proxy with a web socket from :5000 -> :1984 and like I said the origin option hasn't had any affect.

Is there a specific value that is needed or any other value than * should disable that?

@AlexxIT
Copy link
Owner

AlexxIT commented Nov 24, 2022

Origin setting should work in any way. Are you sure you use quotes as in example?

api:
  origin: "*"

go2rtc/cmd/api/ws.go

Lines 16 to 20 in fae59c7

if origin == "*" {
wsUp.CheckOrigin = func(r *http.Request) bool {
return true
}
}

@AlexxIT
Copy link
Owner

AlexxIT commented Nov 24, 2022

This happens when the Host and Origin headers are different:

  • OK: host=192.168.1.123:1984 origin=http://192.168.1.123:1984 (no nginx)
  • OK: host=myhome.duckdns.org origin=https://myhome.duckdns.org (nginx docker port 433:433)
  • ERROR: host=myhome.duckdns.org origin=https://myhome.duckdns.org:4430 (nginx docker port 4330:433)

I'll return dummy fix. It seems that strange nginx configuration in Docker is a common situation.

@NickM-27
Copy link
Contributor Author

NickM-27 commented Nov 24, 2022

@AlexxIT This is my bad actually, I had assumed that * was the default value. Now that I have set

api:
  origin: "*"

it is working just fine

@AlexxIT
Copy link
Owner

AlexxIT commented Nov 24, 2022

Using CORS * in all cases is not a good idea from a security reason. You will be able to remove this setting in the next version.

@AlexxIT AlexxIT changed the title api.ws] upgrade error="websocket: request origin not allowed by Upgrader.CheckOrigin" websocket: request origin not allowed by Upgrader.CheckOrigin Dec 6, 2022
@AlexxIT
Copy link
Owner

AlexxIT commented Dec 6, 2022

Fixed in v0.1-rc.5

@markfrancisonly
Copy link

unfortunately this issue was resolved for me but the error message as returned in my go2rtc version 1.5 logs:
11:58:39.317 ERR github.com/AlexxIT/go2rtc/internal/api/ws/ws.go:96 > host=go2rtc-dns-entry origin=https://homeassistant-dns-entry error="websocket: request origin not allowed by Upgrader.CheckOrigin"

go2rtc.yaml:

api:
  listen: ":1984"    # default ":1984", HTTP API port ("" - disabled)
  origin: "*"        # default "", allow CORS requests (only * supported)

any suggestions?

@AlexxIT
Copy link
Owner

AlexxIT commented Jun 27, 2023

You has some strange config. Maybe self signed certificate. I don't know what means xxx-dns-entry.

@docdawning
Copy link

I'm having this issue as well, but it seems like reports of this have been fairly sparce. Feels like a subtle config issue that users can resolve, if they know what the appropriate course of action is. Kind of a bigger IF there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants