Web UI - Changing Web Root

I’m looking for how to change the web root for MineOS Web UI. I’m using the latest turnkey distro.

For example instead of access the Web UI at:

https://mineos:8443/

I would instead like to access it at:

https://mineos:8443/mineos

This is so I can setup a reverse proxy using directories. Any one know where I make that change?

Thanks in advance!

Can you simply set up your reverse proxy and not operate on 8443?

https://mineos/mineos -> https://mineos:8443?

Or change the port of mineos to something else, e.g., 12345

https://mineos:8443/mineos -> https://mineos:12345

My problem is I have a lot of redirects happening outside of mineos (all via subdirectory) and it isn’t liking me redirecting my subdirectory redirection (it works fine if I use it with “/” instead of “/mineos”

Arguably the problem is I don’t know how to re-write the redirect correctly, but the easy fix seems to be to change the web root path for mineos so that the format matches all my other sites that are working.

Example from my nginx proxy file.

#MineOS
location /mineos {
rewrite /mineos(.*) /$1 break;
proxy_pass https://192.168.2.105:8443/;
proxy_redirect https://192.168.2.105:8443/ https://mydomain.com/mineos;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

Question, do you know how to set up the reverse proxy line for an arbitrary service on an arbitrary port?

If you have a server running a reverse proxy listening at 8443, you simply don’t want MineOS running at 8443–they’d be conflicting. So you can just change 8443 to 12345 in /etc/mineos.conf. Restart the service and voila!

Now create your proxy config as if you had a service running at https://mineos:12345

I’ve got several other reverse proxies working, but they are doing direct external -> internal redirection (from one sub-folder to another) with no issue:

Simple example that doesn’t require a lot of tweaks (as you can see, i’m going from external-ip/sickrage to internal-ip/sickrage)

#Sickrage
location /sickrage {
proxy_pass http://192.168.1.52:8081/sickrage;
proxy_redirect http:// https://;
}

The https://mineos:8443/mineos example was an example of what I want to access internally. Externally my reverse proxy is listening on 80 and 443 (80 redirects to 443)

Why is changing the mineos internal port not a workable solution?

The port isn’t an issue at all. I can get my reverse proxy to work just fine if I don’t try and use a sub directory.

Just as an example, this reverse proxy works great:

#MineOS
location / {
proxy_pass https://192.168.2.105:8443;
}

But I really want to break mineos out into a subdirectory, and in order to do that easily, it’s easiest to just change the web root to “/mineos” instead of “/”

I’m really just hoping there is a script or config that I can go change to (most applications have that ability) alter the web root.

I feel like the port is exactly the issue, but maybe I’m not communicating this right.

Let’s assume, for the sake of demonstration, that MineOS was running on port 12345 internall. What would you add to your reverse proxy config to access it at public facing 8443?

See above, all I would do is change it to this:

location / {
proxy_pass https://192.168.2.105:12345;
}

I have nothing else running on that port ortherwise redirection at the root level wouldn’t work either.

Ninja edit:

I’m not accessing mineos externally at 8443, i’m accessing it via 80 redirected to 443. the reverse proxy takes care of the port redirection internally.

If you wanted it to respond to /mineos, why wouldn’t it be:

location /mineos {

The problem is when mineos responds it doesn’t append the /mineos to the url so i can only communicate one way :confused:

If I could change the web root, when it replies it will have /mineos on it and all will be good.

If you use a reverse proxy, MineOS won’t respond to anything at all when it does URL parsing.

MineOS can respond at 0.0.0.0:12345. Outside requests can come in at 12.23.34.45:8443/mineos and redirected. It can come in at 12.23.34.45:80/mineos. It can come in at literally anything: 12.23.34.45:/fakeout

No matter where it comes in from, your proxy redirect will bring it to 0.0.0.0:12345 and it’ll work

Take a peek at this, it explains the web root issue (that I was able to fix in sickrage)

I’m just looking to do something similar with mineos.

I’m sure there is a way to do it, but it’s going to involve more regular expression and fixing headers in the proxy than I care to do. I really just want to know if it’s possible to change the web root or not. If not, I’ll just move along and figure something else out.

I mean, I reverse proxying can work in the way I’m describing. In fact, this discourse forum runs internally at 6379. Do you type in 6379? No, because nginx rewrites your request from https://discourse.codeemo.com (implied port 443) and rewrites it to 0.0.0.0:6379

I think we’re getting off topic. I really only need to know if the web root can be changed, and if so, how. I can fix it after I have that info.

If you need to change the webroot, you need to change source code in webui.js. I assure you this is a much more difficult, systematically complex, and needlessly error-prone approach.

But it’s here: https://github.com/hexparrot/mineos-node/blob/master/webui.js#L174

Thanks I’ll, dig, I was hoping it was easy as setting up a variable in a config, looks like not that easy.

If you do it the correct way, it’s as easy as one line changed in /etc/mineos.conf and an entry in your nginx config.