LukeChannings / moviematch

MovieMatch for Plex
Other
442 stars 27 forks source link

[Bug] Reverse Proxy not working in v2.0.0-beta.1 in Docker #77

Closed SpaceFanatic closed 3 years ago

SpaceFanatic commented 3 years ago

Describe the bug Following the upgrade to the 2.0 beta everything works fine when accessing MovieMatch from the local IP. However when accessing via moviematch.mydomain.com there is simply the MovieMatch logo at the top, a pulsing red circle in the middle, and a red bar with the word "Disconnected" at the bottom. Docker logs simply state "ERROR Failed to upgrade to a WebSocket Error: request is not acceptable"

No changes were made to the reverse proxy since it was previously working. Nginx subdomain.conf file can be seen below

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name moviematch.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    # enable for ldap auth, fill in ldap details in ldap.conf
    #include /config/nginx/ldap.conf;

    location / {
        # enable the next two lines for http auth
        #auth_basic "Restricted";
        #auth_basic_user_file /config/nginx/.htpasswd;

        # enable the next two lines for ldap auth
        #auth_request /auth;
        #error_page 401 =200 /login;

        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_moviematch MovieMatch;
        proxy_pass http://$upstream_moviematch:8000;
    }

    location /ws {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_moviematch MovieMatch;
        proxy_pass http://$upstream_moviematch:8000;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

}

Screenshots https://imgur.com/a/HsF3lq0

LukeChannings commented 3 years ago

Hey @SpaceFanatic

The develop tag will have the latest beta releases for 2.0 from now on, and the previous release on develop was 1.x.

Quite a lot has changed between 1 and 2, including the WebSocket path.

To fix you problem, rename location /ws to location /api/ws, and everything should work correctly.

Your environment variables should remain valid, so the configuration should continue to work. There are new options with 2.0 though.

SpaceFanatic commented 3 years ago

That did the trick, thanks for the quick response. Been looking forward to 2.0 for awhile and definitely liking what I'm seeing so keep up the great work!

LukeChannings commented 3 years ago

Thanks!

Note: if you feel the need for stability at any point, you can use the latest tag.

aniqueta commented 3 years ago

@LukeChannings I'm running beta2, and I have the above issue when using Cloudflare. No issues when connecting directly through nginx. No issues with other WebSockets through Cloudflare. Any ideas? Thanks for the great app.

Nelinski commented 3 years ago

I'm having issues too with it showing this as plain HTML when using the latest beta:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title translate="no">MovieMatch</title>
    <meta
      name="viewport"
      content="initial-scale=1, width=device-width, viewport-fit=cover"
    />
    <meta name="description" content="MovieMatch helps you pick a movie to watch on Plex" />
    <meta name="theme-color" content="#e64747" />
    <meta
      name="apple-mobile-web-app-status-bar-style"
      content="black-translucent"
    />
    <meta name="msapplication-TileColor" content="#e64747" />
    <link rel="icon" href="./icons/favicon.ico" />
    <link rel="icon" href="./icons/icon.svg" type="image/svg+xml" />
    <link rel="apple-touch-icon" href="./icons/icon-180.png" />
    <link rel="manifest" href="./manifest.webmanifest" />
    <link rel="stylesheet" href="./dist/main.css" />
    <script src="./dist/main.js" type="module" defer></script>
  </head>
  <body data-version="2.0.0-beta.2
" data-root-path="">
    <div id="app"></div>
  </body>
</html>

The config change (location /api/ws) above doesn't fix it. Only two things I can think of:

  1. I'm using Cloudflare
  2. I'm using Authelia

Any ideas?

LukeChannings commented 3 years ago

@Nelinski @aniqueta Can you try lukechannings/moviematch:2.0.0-beta.3?

Nelinski commented 3 years ago

Works now thanks 👍🏻

aniqueta commented 3 years ago

@LukeChannings Thanks for working on this. For me, the beta3 macos-amd64 binary doesn't work. Says it's corrupted and cannot run (after doing chmod +x).

LukeChannings commented 3 years ago

@aniqueta It's not corrupted, macOS is just very particular about code signing and running binaries downloaded from the internet. I've attached a video showing how to run it on macOS.

https://user-images.githubusercontent.com/461449/128991645-74510c24-6a8c-4098-b07a-bc384242d390.mov

aniqueta commented 3 years ago

Thanks @LukeChannings. Those are exactly the steps I'm following, and I'm not getting a signing error. Also double checked I'm downloading the right build (amd64). This is the error I received: Screen Shot 2021-08-12 at 10 39 03 PM I'm on macOS Catalina in case that makes a difference. Also tried Safari in addition to Firefox, if there was really something random happening.

aniqueta commented 3 years ago

Confirmed this worked on another machine running Big Sur. So is this version targeted to Big Sur or newer?

LukeChannings commented 3 years ago

It's possible that Catalina is quarantining the file. You can remove a quarantine attribute with this command:

xattr -rd com.apple.quarantine ./moviematch
aniqueta commented 3 years ago

That fixed the app launch issue. However, the original issue of the app hanging on a pulsating red dot with a "disconnect" button at the bottom remains. When I connect directly to the reverse proxy in front of Moviematch, there is no issue. When I connect through Cloudflare, this issue is present. Anything that I can do to help identify the issue here?

LukeChannings commented 3 years ago

@aniqueta

Can you make a new issue for this?

Please include a screenshot of Chrome's Network tab showing the failed web socket connection (/api/ws).

e.g.

Screen Shot 2021-08-17 at 09 50 42

Note that I'm using CloudFlare too and not experiencing this issue

DebugDax commented 3 years ago

Hello,

I'm using CloudFlare as well and installed beta3 via docker. It works fine internally but when accessing via reverse proxy it loads the page and says "Disconnected" at the bottom. Viewing the Chrome Dev Tools "Network" tab, it's flooding "ws" every second indefinitely until the page is closed. There is nothing being logged for the docker container.

I tried using an internal PLEX_URL and one routed through external DNS domain, both work internally (192.x.x.x) but once accessed via cloudflare domain same results.

Image