webadmin icon indicating copy to clipboard operation
webadmin copied to clipboard

[enhancement] Support for Configurable Base Path in WebAdmin Interface

Open Sofahamster opened this issue 1 year ago • 3 comments

Hi,

I would like to propose an enhancement to add support for a configurable base path (or base URL) for the WebAdmin interface. This feature would make it easier to deploy the interface behind a reverse proxy, such as Nginx, when serving it on a subfolder (subpath) rather than the root URL.

For example: If the WebAdmin interface is served at https://domain.tld/stalwartadmin/, the application should be able to handle the /stalwartadmin/ prefix in URLs seamlessly.

The nginx configuration would probably look like this:

location /stalwartadmin/ {
  proxy_pass https://localhost:8080/;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-Proto $scheme;
}

Many modern web interfaces allow working behind reverse proxies on a sub-path, for example gitea allows setting the ROOT_URL, and the rspamd web interface even works on a sub-path without any configuration.

Sofahamster avatar Dec 25 '24 12:12 Sofahamster

+1 on this. I only have a single server, so all my services need to share one web service.

Hoeze avatar Mar 26 '25 22:03 Hoeze

Any news on this one?

I helped myself for now with a rather complex Nginx proxy:

        # Stalwart
        location ~^/(jmap|.well-known/jmap|settings|webadmin|android-chrome|output-|favicon-|logo|api/(oauth|principal|telemetry|reload|settings)|login|auth|manage|logo.svg|site.webmanifest) {
                proxy_read_timeout 3600;
                proxy_http_version 1.1;
                proxy_set_header Host $http_host;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass https://mail;
        }

As the server runs an other software (Rocket.Chat) which want's to run in the root and also uses /api :(

Btw. I tried setting HTTP Base URL (server.http.url) but it seems to have no effect adding a prefix there.

Ralf

ralfbecker avatar Jun 03 '25 11:06 ralfbecker

This would be quite useful as some email providers look for contact information under the TLD and if none is stored there the email traffic will be blocked. If the web interface could be relocated through a configurable base path, it would be possible to host a one-pager under the TLD

giomf avatar Jun 30 '25 11:06 giomf