@Chrisa, Chris,
Thanks for the excellent and elaborate feedback. It certainly is valuable, even though I only had a quick view at it.
Let me explain a bit about the difficulties, associated with Plesk and its default configuration for Nginx and Apache.
Apache "runs the show", when it comes to webmail: in short, it is pointing to "/usr/share/psa-roundcube".
All "normal" configuration for webmail is actually done on the Apache side, which causes some problems due to the particular construction of the "main" roundcube config file, that (on its turn) is difficult to change manually (given the automated generation of these files) AND is problematic in the sense of the ServerAlias used (default format: webmail.<domain>.<tld>).
Nginx, as a reverse proxy, would be able to provide some options to "work-around" the Apache issues related to automated config generation and chosen ServerAlias.
In fact, it is "would", not "can", in the case of Plesk.
A simple explanation exists: in short, the concerning Apache configuration is more or less copied to (read: translated to) Nginx configuration.
In essence, some of the Apache side flaws are also present on the Nginx side, implying that a very drastic "work-around" on the Nginx side would be required.
In addition, the default Nginx configuration is an "odd ball" and contains many peculiar config settings and even obsolete config files.
This is rather important in your case.
Consider the config files in the directory "/etc/nginx/plesk.conf.d/webmails" and move one .conf file to a file with extension .conf.bak (so Nginx will not recognize it as config), restart Nginx and you will see that actually nothing happens: the webmail can still be opened with the url webmail.<domain>.<tld>.
I made a lot of comments to Plesk Team about the strange or incorrect design structure of Nginx, but to no avail. I have given up.
Anyway, the above mentioned (remarkable) endresult is an illustration, that clearly indicates the problem we are facing:
1 - it is not wise or easy to change something on the Apache side, amongst others for the sake of security and performance,
2 - it is not "good practice" to point Nginx directly to "/usr/share/psa-roundcube" (read: possible, easy to implement, but certainly not wise to do so)
3 - it is not really easy or even possible to achieve all your goals with some simple Nginx directives (read: a complex set of Nginx directives is required)
Point 3 follows from the facts that
a) the server_name directive, starting with webmail.*, in the /etc/nginx/plesk.conf.d/webmail.conf file is making sure that
- any (Nginx based) redirect, from <domain>.<tld>/<name> to the Nginx handled domain webmail.<domain>.<tld>, will result in a forward of requests to the Apache handled "domain" (read: ServerAlias) webmail.<domain>.<tld>, which is good, (and)
- a forward of responses from the Apache handled "domain" to the client, which is bad, since the response header contains webmail.<domain>.<tld>,
b) the creation of an Apache handled domain, being the subdomain webmail.<domain>.<tld>, can rule out the "bad" behaviour, as mentioned in point a,
c) the creation of the (sub-)domain, as mentioned in point b, will make roundcube unavailable on both the domain and subdomain, as a result of default configuration,
and even though point c is an illustration of "good practice" (with undesirable consequences), point c hints a solution.
Nevertheless, the before mentioned solution is a solution involving a dedicated domain for webmail and other domains that allow (Nginx based) redirection to the webmail domain.
Even though this solution does not seem to fit your wishlist, it actually does: all webmail.<domain>.<tld> point to the same, being "/usr/share/psa-roundcube".
Only problem is that I do not want a "fuzz" with two domains, that is not practical and potentially dangerous in terms of management and security.
In short and in conclusion, to satisfy your wishlist, one has to battle some elemental flaws in the default Plesk configuration, in particular that of Nginx.
Why only Nginx? Well, there is not that much wrong with the configuration on the Apache side, it is only inconvenient, in the sense that
- Nginx has to be used to create a "location based solution" (read: "location" as in the Nginx directive), when wanting to have webmail on an URL similar to <domain>.<tld>/<name>
- Nginx has to be used when wanting to keep (Apache and Nginx) default config files intact, whenever possible
and the inconvenience on the Apache side only follows from the fact mentioned in point c above.
As a final remark, I have been testing some of the settings on the Apache and Nginx side and...........available time suddenly did not exist anymore, due to other tasks/jobs.
Apologies for the late response!
Ciao!