LukeChannings/moviematch

[Bug] Resources are not served with the base path env variable and the subpath nginx configuration requires a "/" proxy.

Closed this issue ยท 8 comments

Describe the bug The current nginx configuration for a subpath reverse proxy still requires the base bath "/" to be able to reverse proxy the port 8000 of moviematch. If I have plex.domain.com (which reverse proxies plex) and I want plex.domain.com/moviematch (to reverse proxy moviematch), I'm current unable to do this. If I remember correctly, I was able to do this in the past.

To Reproduce Steps to reproduce the behavior:

  1. Setup moviematch with the "/moviematch" env variable in Docker
  2. ip_with_docker:8000/moviematch does not resolve but ip_with_docker:8000 does

Expected behavior The /moviematch path resolves with all resources served with the /moviematch base path. The nginx sub-path configuration only has one entry to reverse proxy "/moviematch/" without the need for "/"reverse proxy.

Additional context This is a really cool concept and you have implemented it very well. Thank you for making this!

Can you please paste the exact Docker command / config with your PLEX_URL or PLEX_TOKEN redacted?

Can you also paste a reduced example of your nginx config?

Also which version of MovieMatch are you using?

Here's the docker-compose:

moviematch:
   image: lukechannings/moviematch:latest
   container_name: moviematch
   environment:
    PLEX_URL: "http://ip_of_plexvm:32400"
    PLEX_TOKEN: "***"
    BASE_PATH: "/moviematch"
   ports:
      - 8000:8000

nginx conf:

    location ^~ /moviematch/ {
        proxy_pass http://ip_of_moviematch_vm:8000/;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header X-Forwarded-Prefix /moviematch;
    }

I tried this with the latest version on Docker hub and also the latest v2.

Here's a complete docker-compose.yaml + nginx.conf for the latest version:

version: "3.3"
services:
  web:
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - 8000:8000
  moviematch:
    image: lukechannings/moviematch:latest
    environment:
      PLEX_URL: "http://ip_of_plexvm:32400"
      PLEX_TOKEN: "***"
      ROOT_PATH: "/moviematch"
events {
  worker_connections 4096;
}

http {
  server {
    listen 8000;

    location ^~ /moviematch/ {
        proxy_pass http://moviematch:8000/;
        proxy_set_header Upgrade $http_upgrade;
    }
  }
}

You were using BASE_PATH (used in MovieMatch v2) instead of ROOT_PATH (used in MovieMatch v1). I'm considering reverting v2 back, since this is the second time this has caused confusion.

v2

v2 is still unstable, and there's currently a bug with the posters not working in the latest alpha, this will be fixed in 2.0.0-alpha.5.

events {
  worker_connections 4096;
}

http {
  server {
    listen 8000;

    location ^~ /moviematch/ {
        proxy_pass http://moviematch:8000/;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header X-Forwarded-Prefix /moviematch;
    }
  }
}
version: "3.3"
services:
  web:
    image: nginx
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - 8000:8000
  moviematch:
    image: lukechannings/moviematch:2.0.0-alpha.4
    environment:
      PLEX_URL: "http://ip_of_plexvm:32400"
      PLEX_TOKEN: "***"

Ah I see - thanks for pointing that out. I switched it over but I think this still happens. This is my current docker compose:

  moviematch:
   image: lukechannings/moviematch:latest
   container_name: moviematch
   environment:
    PLEX_URL: "http://plexvm.domain:32400"
    PLEX_TOKEN: "***"
    ROOT_PATH: "/moviematch"
   ports:
      - 8000:8000

http://ip_of_vm_with_this_compose:8000 resolves with this screen:
image

Console shows:
image

When I try http://ip_of_vm_with_this_compose:8000/moviematch, I get this:
image

I'm expecting http://ip_of_vm_with_this_compose:8000/moviematch to show the moviematch name/roomcode screen. Is this correct?

Setting ROOT_PATH to /moviematch doesn't mean MovieMatch will be available at /moviematch, instead it rewrites resource requests to be prefixed with /moviematch.

The reverse proxy (in your case nginx) will serve MovieMatch under the /moviematch root, by the MovieMatch server itself will always serve from /.

In v2 the root path is configurable per-request (by setting the x-forwarded-prefix header), this means that paths can be correct for both the reverse proxy and direct loading. That won't work in v1 because the prefix will always affect all requests.

Gotcha. Thanks for clearing that up. I should have checked the nginx proxy of MovieMatch - it was (and still is) working!

To clarify for v2: Users can start spin up an instance of MovieMatch without setting a BASE_PATH but still have it available on http://nginx/moviematch by setting the x-forwarded-prefix header. So this way the http://moviematch and http://nginx/moviematch will both work? If so, is the BASE_PATH variable meant to affect direct loading/in which situations would users set the BASE_PATH variable?

That's all correct.

With regards to BASE_PATH vs x-forwarded-prefix: BASE_PATH does the same as ROOT_PATH in v1, and affects all requests, I wouldn't recommend using it if it's possible to use x-forwarded-prefix, but it's there in case users need it.

This makes sense! Thank you for helping me with this.

I'm glad MovieMatch exists. If I learn TypeScript in the future, I'll try to contribute.