jlesage / docker-baseimage-gui

A minimal docker baseimage to ease creation of X graphical application containers
MIT License
1.2k stars 179 forks source link

[Feature Request] Web path prefix support #139

Closed sgpublic closed 2 months ago

sgpublic commented 3 months ago

As the title says, if web prefixes are supported, multiple instances can be deployed on a single domain name without conflicts.

There is already a PR: #42, but it is too old to be merged into the current repository.

Is there any plan to support this feature or accept PR? Thank you!

jlesage commented 3 months ago

Could you provide more details about the use case ? If you are running multiple instances, I guess they each run on different ports ? So you need to run them behind a reverse proxy or something like that ?

sgpublic commented 3 months ago

Yes, I need to run noVNC behind a reverse proxy.

Specifically, I built my own image using docker-baseimage-gui, and then used noVNC and Web authentication (WEB_AUTHENTICATION). Since I need to deploy multiple instances at the same time and also need public HTTPS access, I hope to access different instances through paths with different prefixes of a single domain name.

For example:

Currently, if I enable WEB_AUTHENTICATION, it will be forced to jump to /login/ when accessing. I have tried the following configuration:

    location ~ /container/instance1 {
        include /etc/nginx/common.d/listen_location.conf;
        rewrite ^/container/instance1$ / break;
        rewrite ^/container/instance1(.*)$ $1 break;
        proxy_redirect https://$server_name/ /container/instance1/;
        proxy_pass https://$NAS_IP:5800;
    }

But the login interface on the web page uses /login/login: /rootfs/opt/noVNC/login/index.html#L35, external configuration alone can no longer meet this requirement.

jlesage commented 3 months ago

Ok, so yes, the way to go is to use the reverse proxy to server the interface of a container under a different path. You can check one of my container's documentation for an example of proxy configuration (e.g. https://github.com/jlesage/docker-crashplan-pro?tab=readme-ov-file#routing-based-on-url-path).

The bug/problem, as you mentioned, is the login page that uses absolute path. This can be fixed.

Is it working well without WEB_AUTHENTICATION enabled ?

sgpublic commented 3 months ago

Is it working well without WEB_AUTHENTICATION enabled ?

Yes, it works well after I modified the configuration:

    location = /container/instance1 {
        return 302 https://$server_name/container/instance1/;
    }
    location ~ /container/instance1/ {
        include /etc/nginx/common.d/listen_location.conf;
        rewrite ^/container/instance1(.*)$ $1 break;
        proxy_redirect https://$server_name/ /container/instance1/;
        proxy_pass https://$NAS_IP:5800;
    }

The bug/problem, as you mentioned, is the login page that uses absolute path. This can be fixed.

I modified /rootfs/opt/noVNC/login/index.htm locally:

                     <div id="loginStatus" class="alert alert-danger mb-4 d-none" role="alert">
                     </div>
-                    <form action="/login/login" method="post" id="loginForm" novalidate>
+                    <form action="login" method="post" id="loginForm" novalidate>
                     <div class="form-floating mb-3">

Now it works fine when WEB_AUTHENTICATION is enabled.

jlesage commented 3 months ago

I found few other things that doesn't work well (fonts, logout, etc). I'm working on fixing these.

sgpublic commented 3 months ago

I found few other things that doesn't work well (fonts, logout, etc). I'm working on fixing these.

Hey, just checking in—any idea when we might get the next release? 😊

jlesage commented 2 months ago

Fixed in version 4.6.4.