virtualmin / virtualmin-gpl

Virtualmin web hosting control panel for Webmin
https://www.virtualmin.com
GNU General Public License v3.0
312 stars 97 forks source link

autoconfig url should be scriptalias and not redirect #760

Open aqueos opened 6 months ago

aqueos commented 6 months ago

hi,

for autoconfiguration of emails virtualmin put

    Redirect /mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
    Redirect /.well-known/autoconfig/mail/config-v1.1.xml /cgi-bin/autoconfig.cgi
    ScriptAlias /AutoDiscover/AutoDiscover.xml /home/mailadmin/cgi-bin/autoconfig.cgi
    ScriptAlias /Autodiscover/Autodiscover.xml /home/mailadmin/cgi-bin/autoconfig.cgi
    ScriptAlias /autodiscover/autodiscover.xml /home/mailadmin/cgi-bin/autoconfig.cgi

but for me the 2 first line fails because the template has no cgi-bin definition. It would be more consistent to have


    ScriptAlias /mail/config-v1.1.xml           /home/mailadmin/cgi-bin/autoconfig.cgi
    ScriptAlias /.well-known/autoconfig/mail/config-v1.1.xml    /home/mailadmin/cgi-bin/autoconfig.cgi  
    ScriptAlias /AutoDiscover/AutoDiscover.xml /home/mailadmin/cgi-bin/autoconfig.cgi
    ScriptAlias /Autodiscover/Autodiscover.xml /home/mailadmin/cgi-bin/autoconfig.cgi
    ScriptAlias /autodiscover/autodiscover.xml /home/mailadmin/cgi-bin/autoconfig.cgi

and not rely on a cgi-bin directive for 50% of the case only :)

best regards, Ghislain.

jcameron commented 6 months ago

You know, I'm not actually sure why we did it with a redirect instead of a scriptalias! Does this cause any problems though?

aqueos commented 6 months ago

hi Jamie,

on my side it make it fail on thunderbird for all template not having a cgi-bin dir scripting directory directive. As cgi are not really used nowadays this is more and more the case. Changing it to scriptalias make it work for TB as well as for the microsoft clients.

This is why i think it could be changed to be a script alias that seems more robust to me as it does not rely on another part of the template to work.

best regards, Ghislain.

jcameron commented 6 months ago

What error are you getting in Thunderbird exactly? From the point of view of the mail client, there should be no difference..

aqueos commented 6 months ago

well like i said if your apache template has no

<directory /home/me/cgi-bin >
    Options +ExecCGI
</Directory>

or

ScriptAlias "/cgi-bin/" "/usr/local/apache2/cgi-bin/"

then you redirect just fail in a 404.

All apache template is not sure to have it.

regards, Ghislain.

jcameron commented 6 months ago

We do have those in the default Virtualmin apache template though...

aqueos commented 6 months ago

yes it is but, when did this template was designed :)

nobody use cgi-bin in 2024 that i know off, so this directive will not be here anymore in new templates.

They will just be in legacy templates.

Again, the configuration discriminate the thunderbid system vs the microsoft one making the micorsoft propietary one more robust than the opensource one. i am just pointing out an issue i met.

If this does not change i will make a patch that will add ScriptAlias /cgi-bin/autoconfig.cgi /home/mailadmin/cgi-bin/autoconfig.cgi so the redirect ends on a scriptalias.

but my postcreate script tend to be quite large allready :)

regards, Ghislain.

jcameron commented 6 months ago

The autoconfig script has to run via CGI one way or another though, as it doesn't just return static XML - it transforms the email address provided into a Virtualmin mailbox name.

iliajie commented 6 months ago

Jamie, despite everything discussed here in regards to CGI, shouldn't we be more consistent and just always use ScriptAlias?

jcameron commented 6 months ago

Ideally yes .... maybe. But if it works as it is now, I'm reluctant to add complexity by making changes.