title: Roundcube & Dovecot inside Docker Containers
body: <p>I have a Docker stack for my mail server.</p>
  
  <p>My <code>docker-compose.xml</code> contains</p>
  
  <pre><code>version: '3.7'
  services:
      postfix:
          ...
      dovecot:
          ....
          ports:
              - "110:110"
              - "995:995"
              - "143:143"
              - "993:993"
          networks:
              - mail
          ....
      roundcube:
          image: roundcube/roundcubemail
          container_name: roundcube
          environment:
              - ROUNDCUBEMAIL_DEFAULT_HOST=dovecot
               # - ROUNDCUBEMAIL_DEFAULT_PORT=993
          networks:
              - proxy
              - mail
  </code></pre>
  
  <p>I also have a Nginx container running as a proxy for all my web applications.  For roundcube I have</p>
  
  <pre><code>set $roundcube_upstream http://roundcube;
  location /roundcube/ {
      rewrite ^/roundcube/(.*) /$1 break;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      proxy_set_header Host $host;
      proxy_pass $roundcube_upstream;
  }
  </code></pre>
  
  <p>With that configuration it's working.  I can go to <a href="https://www.mydomain.be/rouncube/" rel="nofollow noreferrer">https://www.mydomain.be/rouncube/</a> and I can login.  The default port is 143.  So roundcube si connecting to dovecot with imap.</p>
  
  <p>Now, I'd like to use port 993 and ssl/tls.</p>
  
  <p>I tried decommenting the ROUNDCUBEMAIL_DEFAULT_PORT=993, but also using ssl://dovecot or tls://dovecot or ssl://mail.mydomain.be, ... but nothing is working.</p>
  
  <p>When I click on the connextion button, after a while I receive an nginx error page.  In my proxy logs I can see</p>
  
  <pre><code>2019/01/31 09:29:25 [error] 460#460: *82483 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 194.197.210.75, server: www.mydomain.be, request: "POST /roundcube/?_task=login HTTP/1.1", upstream: "http://172.18.0.9:80/?_task=login", host: "www.mydomain.be", referrer: "https://www.mydomain.be/roundcube/"
  </code></pre>
  
  <p>And I don't understand where the <a href="http://172.18.0.9:80/?_task=login" rel="nofollow noreferrer">http://172.18.0.9:80/?_task=login</a> is coming from ?</p>
  
  <p>With Thunderbird client I can connect on that port.</p>
  
  <p>What's the problem ?</p>
  
  <h1>Edit</h1>
  
  <p>Using </p>
  
  <pre><code>        - ROUNDCUBEMAIL_DEFAULT_HOST=ssl://dovecot
          - ROUNDCUBEMAIL_DEFAULT_PORT=993
  </code></pre>
  
  <p>I now have a response : connection error to the storage server.</p>
  
  <p>In my roundcube logs :</p>
  
  <pre><code>errors: &lt;1db522a3&gt; IMAP Error: Login failed for me@mydomain.be from 172.18.0.8(X-Real-IP: ...,X-Forwarded-For: ...). Could not connect to ssl://dovecot:993: Unknown reason in /var/www/html/program/lib/Roundcube/rcube_imap.php on line 196 (POST /?_task=login&amp;_action=login)172.18.0.8 - - [31/Jan/2019:13:57:37 +0100] "POST /?_task=login HTTP/1.1" 200 3089 "https://www.mydomain.be/roundcube/?_task=login" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0"
  </code></pre>
  
  <p>and in dovecot logs</p>
  
  <pre><code>2019-01-31T13:57:38.002653+01:00 536ff3507263 dovecot: auth: Debug: auth client connected (pid=35),
  2019-01-31T13:57:38.010096+01:00 536ff3507263 dovecot: imap-login: Disconnected (no auth attempts in 0 secs): user=&lt;&gt;, rip=192.168.240.3, lip=192.168.240.2, TLS, session=&lt;nVssksCAT7LAqPAD&gt;
  </code></pre>
  
  <p>So dovecot is well contacted but ... ?  Don't know whats the problem.</p>