mohsenasm / swarm-dashboard

A Simple Monitoring Dashboard for Docker Swarm Cluster
MIT License
162 stars 26 forks source link

Context root support #28

Closed trajano closed 1 year ago

trajano commented 1 year ago

Can you make it so it works with a different context root e.g. https://mysserver.com/swarm-dashboard like the CTX_ROOT variable of swarm visualizer?

I think this may be the solution

trajano commented 1 year ago

Just tried to do it myself, failed miserably :P I am no nodeJS express dev that's for sure:

I started with

/**
 * The context root of the web application.
 * @type {string}
 */
const contextRoot = process.env.CTX_ROOT || "/";

But I can't seem to figure out how to link

const router = express.Router()
app.use(contextRoot, router)

with the new path.

mohsenasm commented 1 year ago

I just added this feature with env var PATH_PREFIX. Could you check it? Docker image: mohsenasm/swarm-dashboard:dev_path_prefix

trajano commented 1 year ago

Yup looks good. I was reading up on how to code in elm for this last bit to get the variable

localWebsocket location =
    if location.protocol == "https:" then
        "wss://" ++ location.host ++ "/stream"
    else
        "ws://" ++ location.host ++ "/stream"

But you beat me to it :D

image

I also verified that it is using the proper paths to in the dev tools

image
trajano commented 1 year ago

So can we have a v2.1 soon?

mohsenasm commented 1 year ago

Yeah, v2.1 is available now.