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

2.0.0 Web UI doesn't work behind reverse proxy #340

Closed
database64128 opened this issue May 24, 2022 · 9 comments
Closed

2.0.0 Web UI doesn't work behind reverse proxy #340

database64128 opened this issue May 24, 2022 · 9 comments
Assignees
Labels

Comments

@database64128
Copy link
Contributor

I'm using nginx to proxy https://cube64128.xyz/restreamer/ to Restreamer's 8080 port. The UI doesn't work properly because the paths are wrong:

image

The web UI should use relative paths, or allow the admin to configure a custom path.

@HeliosLHC
Copy link

HeliosLHC commented May 25, 2022

I have the same issue. If you view the source in the UI's repo here: https://github.com/datarhei/restreamer-ui/blob/8dbdb3dfc90958d7cbe162b1c826ca7a75666d34/public/index.html
the paths are hard coded at build time using the "%PUBLIC_URL%" variable. Until this can be configured at runtime, the only resolution for reverse proxy users with restreamer as a subpath will need to build their own UI with the "%PUBLIC_URL%" set to their own subpath or set it's value to "./" to make all paths, relative paths.

I tried manually editing the static UI files in the Docker container to replace the paths in the built files which got it the interface to load but the rest of the UI is still broken (some hard coded paths i didn't get around to finding are still broken)

@kallenp
Copy link

kallenp commented May 25, 2022

Any idea howto solve this issue for beginners and not programmers ?

@MattWAnderson
Copy link

MattWAnderson commented May 26, 2022

This works correctly for me behind a NGINX reverse proxy.

server {
    listen 443;
    server_name <web domain>;
    ssl on;

location = / {
    proxy_pass http://serverip:port/streamlink.html;
}

    location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://serverip:port/;
    }

}

The double listing is to remove the need for the extra page.html

@HeliosLHC
Copy link

HeliosLHC commented May 26, 2022

@MattWAnderson
Hi Matt, I believe in your Nginx config you are performing a root-to-root proxy where external "/" is mapped to the internal "/". In your case, it's mapped to the internal "/l" which is effectively the internal root. Since right now, the UI paths are hardcoded as absolute paths (non-relative), there aren't any issues for you.

The issue described in the original post (and mine as well) is using mapping an external subpath to the internal root path which is different from your configuration. An example nginx config (with domain: example.com) for that would be the following:

location /somesubpath {
    proxy_pass http://serverip:port/;
}

When the UI requests the path "/example.css", Nginx 404s as it can't find the path (outside of the defined location route). The correct path should have been "/somesubpath/example.css"

@jstabenow
Copy link
Member

Hey folks,
Release v2.1.0 is out now and the %PUBLIC_URL% is removed. Thanks for your hint 👍
It should work now.

Other solution: Use our hosted Restreamer-UI:
https://restreamer.datarhei.com?address=https://your-restreamer-url:port (no /)

Mixed content must be allowed for HTTP: Help

@database64128
Copy link
Contributor Author

Updated Restreamer to v2.1.0 and the UI still doesn't work:

image

Please reopen this issue.

@ioppermann ioppermann reopened this Jun 7, 2022
@ioppermann
Copy link
Member

True, this is still broken. A fix is in the pipeline and will be part of the next release.

ioppermann added a commit to datarhei/core that referenced this issue Jun 7, 2022
In order for the UI to work properly with a relative %PUBLIC_URL% the
route for the UI requires a / at the end. This commit is enforcing
this. As a consequence, if the UI is behind a reverse proxy, it will
still load properly.
jstabenow added a commit to datarhei/core that referenced this issue Jun 23, 2022
Commits (Ingo Oppermann):
- Add experimental SRT connection stats and logs
- Hide /config/reload endpoint in reade-only mode
- Add SRT server
- Create v16 in go.mod
- Fix data races, tests, lint, and update dependencies
- Add trailing slash for routed directories (datarhei/restreamer#340)
- Allow relative URLs in content in static routes

Co-Authored-By: Ingo Oppermann <[email protected]>
@svenerbeck
Copy link
Member

Hi @database64128
We are closing your issue #340.

This may be due to the following reasons:

  • Problem/inquiry has been solved
  • The ticket remained unanswered by you for a more extended time
  • The problem was explained and handled in another ticket

You can reopen this ticket at any time!

Please do not open related tickets twice. Always answer/ask in the original issue with the same problem.

Your datarhei team
//Sven

@HeliosLHC
Copy link

Hello, I'm still experiencing this issue in 2.3.

The UI loads fine now after the changes but the API endpoint (after looking through the source code) is still statically pointing to the root path.

The code currently constructs the API endpoint URL from the host domain for the current page only. This means if a subpath is used, the API URL will not be correctly constructed.

As the web-ui is statically generated (and a dynamic generation adds way too much overhead), one potential solution is to add a new configuration value that contains the subpath string that the server can pass as a cookie to the browser when serving the static files.

The JS code can then be modified to parse the cookie data for the subpath value to appropriately construct the API URL.

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

No branches or pull requests

7 participants