Syncplay / syncplay

Client/server to synchronize media playback on mpv/VLC/MPC-HC/MPC-BE on many computers
http://syncplay.pl/
Apache License 2.0
2.11k stars 214 forks source link

"Not a json encoded string HTTP/1.1 400 Bad Request" running behind nginx reverse proxy #461

Closed devmgardner closed 2 years ago

devmgardner commented 3 years ago

Describe the bug Syncplay-server is running on Ubuntu Server 20.04, with both a dedicated LAN and WAN IP. I have a subdomain forwarded to my WAN IP, ports 8998 and 8999 are forwarded in my router to port 8999 on my server, and have the rules set up in ufw (and have reloaded). Syncplay is set to listen on port 8998, and I have an nginx reverse proxy running, listening on port 8999 and redirecting to http://127.0.0.1:8998. I am able to connect to the server using both the LAN IP and my subdomain, and can connect using my subdomain while using a VPN, however I receive an error and am immediately disconnected from the server. I have found nothing in the syslog to tell me why my client on my MacBook cannot connect.

To Reproduce Steps to reproduce the behavior:

  1. Set up syncplay-server behind a reverse proxy using nginx, run with following options: --password --port
  2. Attempt to connect from MacOS.

Expected behavior After resolving nginx proxy issues, I was expecting the client to connect and stay connected.

Screenshots syncplay bash script: syncplay-server --port 8998 --password password

/etc/nginx/sites-available/movies.conf:

server {
  listen  80;
  listen  [::]:80;
  location / {
    proxy_pass http://127.0.0.1:8998;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    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-Proto $scheme;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_set_header X-Forwarded-Host $http_host;
  }

}

server {
  listen 8999;
  listen [::]:8999;
  server_name movies.devinmgardner.com;
  location / {
    proxy_pass http://127.0.0.1:8998;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    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-Proto $scheme;
    proxy_set_header X-Forwarded-Protocol $scheme;
    proxy_set_header X-Forwarded-Host $http_host;
  }

}

Configuration of syncplay client on MacBook:

Screen Shot 2021-09-06 at 2 30 00 PM

Error message from syncplay client on MacBook:

Screen Shot 2021-09-06 at 2 30 32 PM

Version and platform:

Additional context I mainly want to use nginx because I am currently hosting another site on another subdomain, so I need some form of reverse proxy as Google Domains does not allow for domain forwarding with port numbers attached. I need a domain name specifically because I'm hosting this for my family while my dad's out of the country getting another medical degree.

Et0h commented 3 years ago

Syncplay was not designed to work with proxies so it falls outside our supported use cases. Is https://github.com/weeb-poly/syncplay-proxy of any use?

devmgardner commented 3 years ago

Syncplay was not designed to work with proxies so it falls outside our supported use cases. Is https://github.com/weeb-poly/syncplay-proxy of any use?

Good question! I installed it, and have no clue what to do from here. Nginx/websockets are still fairly new to me.

daniel-123 commented 2 years ago

@devmgardner In general Nginx reverse proxy is specifically for HTTP(S) and tiny selection of other protocols. Syncplay doesn't use HTTP, so this wont work.

You could use a service offering free subdomains like duckdns to work around this issue.

devmgardner commented 2 years ago

@devmgardner In general Nginx reverse proxy is specifically for HTTP(S) and tiny selection of other protocols. Syncplay doesn't use HTTP, so this wont work.

You could use a service offering free subdomains like duckdns to work around this issue.

I had a duckdns subdomain before I set up my own domain, I appreciate the info! I was actually able to get this to work as another subdomain on my main domain; instead of attempting to use a reverse proxy, I set up an SRV record for my domain to point to my forwarded port on my router and now it works properly. Thanks again!