IrosTheBeggar / mStream

The easiest music streaming server available
http://mstream.io
GNU General Public License v3.0
2.22k stars 188 forks source link

Subfolder reverse proxy problem #331

Open SSoft7 opened 3 years ago

SSoft7 commented 3 years ago

Already checked issue #223 and using the latest release.

The logout and login feature breaks when under subfolder reverse proxy because logging out sets the location response header to /login instead of /path/subpath/login Similarly logging in redirects to the root domain.

IrosTheBeggar commented 3 years ago

This should be fixed in the latest commit. Let me know if you have any more problems

SSoft7 commented 3 years ago

Unfortunately, I'm still having the problem.

Here is my Nginx configuration -

location ^~ /mstream/subpath/ {
    proxy_pass http://127.0.0.1:45021/;
    include proxy.conf;
}

It is still sending /login, I'm not sure why, I'm using the exact new version 5.7.2 (built from source) image

Maybe you can check using my configuration if you have Nginx installed.

IrosTheBeggar commented 3 years ago

I just pushed a commit that has another fix based on this post: https://stackoverflow.com/questions/1655065/redirecting-to-a-relative-url-in-javascript

It's basically the fix I made but through a different window API. If this doesn't work there's just on solution left, doing a string search and replace of the entire URL string on each redirect.

Let me know if this works. I'm trying to avoid setting up an entire test deployment just for this bug

SSoft7 commented 3 years ago

Not working, unfortunately :-(

IrosTheBeggar commented 2 years ago

I made some changes to redirect behavior. This should be fixed now

SSoft7 commented 2 years ago

Alright, So 1) Login is working fine. 2) Logout still redirects to /login/ 3) Both 1> and 2> can be fixed by adding the following directive in nginx proxy_redirect '/login' '/mstream/subpath/login'; 4) There is a link to the admin panel at the sidebar that opens /admin on the root domain. That needs fix on your side. Opening that page redirects to /admin/ as well. <div id="admin-side-link" class="side-nav-item my-waves" onclick="window.open('./admin', '_blank');">

maxim-kukushkin commented 2 years ago

What is the latest status of this feature? Is it still only available as a separate branch? Is there any Docker image with it by any chance? If relative URLs shouldn't be enabled by default, can it be done via an admin setting vs. custom builds from a branch?

maxim-kukushkin commented 2 years ago

Just to give some context: the reason this feature is quite important is that normally you'd want to protect the communication by SSL (especially when user/password are involved). Deploying mStream in a subdomain would require a wildcard certificate and wildcard certificates can be way much more expensive than single-domain one.

For example, in my dynamic DNS plan I have one SSL certificate included. However, this certificate can only be issued for a specific domain. Adding subdomains would mean buying a separate certificate for ~$150/year. And this cost is just to be able to run mStream, cause I have no other applications which would require a subdomain.

TermeHansen commented 1 year ago

I also have problem in using mstream behind a reverse_proxy on a subpath. I'm using Caddy and mstream from docker.

with a subpath (here /mstream) I get:

mstream  |              ____  _
mstream  |    _ __ ___ / ___|| |_ _ __ ___  __ _ _ __ ___
mstream  |   | '_ ` _ \\___ \| __| '__/ _ \/ _` | '_ ` _ \
mstream  |   | | | | | |___) | |_| | |  __/ (_| | | | | | |
mstream  |   |_| |_| |_|____/ \__|_|  \___|\__,_|_| |_| |_|
mstream  | v5.11.4

mstream  | 2023-04-10T12:46:25.420Z error: Server error on route /mstream/
mstream  | WebError: Authentication Error
mstream  |     at /opt/mstream/src/api/auth.js:54:25
mstream  |     at Layer.handle [as handle_request] (/opt/mstream/node_modules/express/lib/router/layer.js:95:5)
mstream  |     at trim_prefix (/opt/mstream/node_modules/express/lib/router/index.js:328:13)
mstream  |     at /opt/mstream/node_modules/express/lib/router/index.js:286:9
mstream  |     at Function.process_params (/opt/mstream/node_modules/express/lib/router/index.js:346:12)
mstream  |     at next (/opt/mstream/node_modules/express/lib/router/index.js:280:10)
mstream  |     at SendStream.error (/opt/mstream/node_modules/serve-static/index.js:121:7)
mstream  |     at SendStream.emit (node:events:513:28)
mstream  |     at SendStream.error (/opt/mstream/node_modules/send/index.js:270:17)
mstream  |     at SendStream.onStatError (/opt/mstream/node_modules/send/index.js:417:12)

Any ideas of what this is about?