add_webprefix() breaks reverse proxies: causes 404 errors for all links in left.cgi

Introduced in 9.02 via newleft.cgi and now the default in 9.2 left.cgi, the method add_webprefix() totally breaks the Virtualmin administration interface with 404 errors when it is delivered via a reverse proxy.

I upgraded VM and the theme today and since then all Virtualmin links in left.cgi have duplicated the reverse proxy URL prefix, which breaks the links entirely. One example:

div class='leftlink' a href='/private/webmin/private/webmin/virtual-server/edit_domain.cgi?dom=119714900313433' target=right Edit Virtual Server /a /div

The reverse proxy's base URL is https://domain.tld/private/webmin/

This worked fine in 9.02 using left.cgi.

The unchanged settings in config are:

/etc/webmin/config:39:webprefixnoredir=1 /etc/webmin/config:40:webprefix=/private/webmin

The fix is attached.



Thanks - I will include this fix in the next release.

Automatically closed -- issue fixed for 2 weeks with no activity.

Automatically closed -- issue fixed for 2 weeks with no activity.

This needs re-examining! Today I discovered (not sure why this didn't show up previously) that with this fix in place although the VirtualMin links are correct the Webmin links are broken. For example the link from left.cgi to Servers > Postfix Mail Server which should be

div class='linkindented' a href='/private/webmin/postfix/' target=right Postfix Mail Server /a /div


div class='linkindented' a href='/postfix/' target=right Postfix Mail Server /a /div

Revised patch:

  1. use '!~' not ! $var =~ /.../
  2. use 'm,' to change regexp start-stop markers

Tested with webmin and virtualmin

The actual fix I submitted is different from the first patch on this bug.