Path to email client autoconfiguration file

Hello everyone, I hope I’m not asking a question I could have found the answer somewhere, but I didn’t so I try here :wink:

The YNH instance I’m referring to after is installed in a vm and therefore the main machine has a firewall forwarding requests to YNH and other vms.

In order for a mail client to be able to configure automatically IMAP and SMTP ports, when configuring an account, I think it has to make a request to the server. I guess that this request is probably made to mydomain.tld/some/path/ but the firewall of the main machine is probably blocking it which make autoconfiguration fail, and users have to fill in the configuration manually, which is not obvious for many people.
I was wondering what is the url mydomain.tld/some/path/ that fetches the autoconfiguration file, so I can forward it to the YNH vm from the main machine.
Any idea how I can figure out what is that url?

Ehlo !

The url is domain.tld/.well-known/domain.tld/autoconfig/mail/config-v1.1.xml i believe :wink:

Edit: you can find it if you look at nginx’s logs when attempting to configure thunderbird

Hey, thank you :slight_smile:
Checking the logs of the main machine, I can see a request to domain.tld/.well-known/autoconfig/mail/config-v1.1.xml but it keeps answering 404 even when I forward it to the vm. I tried requesting yunohost.domain.tld/.well-known/autoconfig/mail/config-v1.1.xml with the browser (yunohost.domain.tld forwards everything to YNH vm) and it also reply 404 and thunderbird still cannot fetch the config.

If I try yunohost.domain.tld/.well-known/domain.tld/autoconfig/mail/config-v1.1.xml in the browser, it forwards to the SSO (even when logged in). Not sure what’s going one.

Hmm do you have the corresponding file in /var/www/.well-known ?

Yep, the file exists (/var/www/.well-known/domain.tld/autoconfig/mail/config-v1.1.xml), and it seem to contain what it should (from what I can imagine).
So I don’t understand why when I check the url it redirects to the SSO, and secondly, I don’t see how thunderbird could find the config even if it was returned, since thunderbird seem to make a request without the “domain.tld” part (= it requests /.well-known/autoconfig/mail/config-v1.1.xml).

Hmmmyea I think the answer lies in how nginx is configured :wink:

Can you check that your nginx conf is “up to date” with yunohost service regen-conf nginx ?

(Or yunohost service regen-conf nginx --dry-run -d to see the diff)

I ran to fast yunohost service regen-conf nginx before seeing you proposed also yunohost service regen-conf nginx --dry-run -d, so I didn’t get the diff, but with up to date nginx config, the problem remains.

Well eh okay, I think if you want to investigate further then maybe running grep -nr "well-known" /etc/nginx/ will point you to the corresponding line, and then you can try to see if the right locations are pointing to the right files …

It looks like this, which seemed to make sense to me

location /.well-known/autoconfig/mail/ {
    alias /var/www/.well-known/domain.tld/autoconfig/mail/;
}

From this I understand that if I request domain.tld/.well-known/autoconfig/mail/config-v1.1.xml I should get the config properly, and not be redirected to yunohost SSO, no?
Also requesting yunohost.domain.tld/.well-known/autoconfig/mail/config-v1.1.xml I should get another config for the subdomain yunohost.domain.tld.

Hmmm I don’t really get what’s wrong then.

Hmm the nginx conf seem right, but this is the log I get when I try to connect:

2019/02/20 14:54:28 [error] 371#371: *160021 open() "/usr/share/nginx/html/.well-known/autoconfig/mail/config-v1.1.xml" failed (2: No such file or directory), client: 192.168.122.1, server: domain.tld, request: "GET /.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=user%40domain.tld HTTP/2.0", host: "domain.tld"

I guess it shouldn’t be looking in /usr/share/nginx/html/.

Also be careful that the .well-known thing is done in HTTP, not in HTTPS.

Ok, I wanted to ask at the beginning if it could be a problem if the request is https, but I didn’t, but the whole problem must come from that, because the firewall of the main machine is caddy and is making all traffic automatically htttps.

Yep, it worked in http :slight_smile:
Thank you, sorry for the noise :confused:

1 Like

So to answer fully the original question in two lines:

  1. the proper url to the config is: domain.tld/.well-known/autoconfig/mail/config-v1.1.xml
  2. and it must be an http request, not https

Thanks @Aleks for all the help :slight_smile:

1 Like

Well trying with K9 mail, by default it configures SSL/TLS and port 465 for sending. So maybe there’s still a problem I don’t know, but I guess if there is it must come from my caddy https/http configuration that’s right and not from yunohost.