I have proper setup for MAILCOW_HOSTNAME and DNS Rules were set correctly as for Jira Infrastructure on the same machine with HAProxy I have HTTPS on subdomains fully working. HAProxy is turned off now.
I can open Mailcow at URL https://127.0.0.1/ and see that the certificate verified by Mailcow and the browser set the connection as not secure. I cannot open the page using the domain name.
In mailcowdockerized_acme-mailcow_1 I see log:
2024-08-22 22:37:33 Thu Aug 22 22:37:33 EEST 2024 - Initializing, please wait...
2024-08-22 22:37:34 Thu Aug 22 22:37:34 EEST 2024 - Using existing domain rsa key /var/lib/acme/acme/key.pem
2024-08-22 22:37:34 Thu Aug 22 22:37:34 EEST 2024 - Using existing Lets Encrypt account key /var/lib/acme/acme/account.pem
2024-08-22 22:37:34 Thu Aug 22 22:37:34 EEST 2024 - Detecting IP addresses...
2024-08-22 22:37:43 Thu Aug 22 22:37:43 EEST 2024 - OK: 188.239.100.183, 0000:0000:0000:0000:0000:0000:0000:0000
2024-08-22 22:37:58 Thu Aug 22 22:37:58 EEST 2024 - No A or AAAA record found for hostname mail.somedomain.com
2024-08-22 22:37:58 Thu Aug 22 22:37:58 EEST 2024 - Cannot validate any hostnames, skipping Let's Encrypt for 1 hour.
2024-08-22 22:37:58 Thu Aug 22 22:37:58 EEST 2024 - Use SKIP_LETS_ENCRYPT=y in mailcow.conf to skip it permanently.
2024-08-22 22:37:58 OK
2024-08-22 22:37:33 Could not find certificate from <stdin>
and in NGINX I see this logs:
2024-08-22 22:36:56 2024/08/22 22:36:56 [warn] 1#1: conflicting server name "autoconfig.*" on 0.0.0.0:443, ignored
2024-08-22 22:36:56 nginx: [warn] conflicting server name "autoconfig.*" on 0.0.0.0:443, ignored
2024-08-22 22:36:56 2024/08/22 22:36:56 [warn] 1#1: conflicting server name "mail.somedomain.com" on [::]:443, ignored
2024-08-22 22:36:56 nginx: [warn] conflicting server name "mail.somedomain.com" on [::]:443, ignored
If I change
a configuration like this:
HTTP_PORT=80
HTTP_BIND=0.0.0.0
HTTPS_PORT=443
HTTPS_BIND=0.0.0.0
Access to Mailcow using https://127.0.0.1/ and https://mail.somedomain.com blocked by NGINX with error 502 Bad Gateway and errors in logs:
2024-08-22 23:19:22 2024/08/22 23:19:22 [error] 20#20: *6 connect() failed (111: Connection refused) while connecting to upstream, client: 172.22.1.1, server: mail.somedomain.ua, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:9000/", host: "mail.somedomain.ua"
2024-08-22 23:19:24 2024/08/22 23:19:24 [error] 22#22: *9 connect() failed (111: Connection refused) while connecting to upstream, client: 172.22.1.1, server: mail.somedomain.ua, request: "GET / HTTP/2.0", upstream: "http://127.0.0.1:9000/", host: "127.0.0.1"
I checked network using command docker network inspect mailcow-network and defined that containers network is empty:
andrii@andrii-MS-7B33:~/IdeaProjects/Infrastructure/mailcow/mailcow-dockerized$ docker network inspect mailcow-network
[
{
"Name": "mailcow-network",
"Id": "d47a599e70311a42adc06eae5e4cbd190f342d3231698ff5aa3b4690e434e94d",
"Created": "2024-08-19T19:25:31.808137982Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.20.0.0/16",
"Gateway": "172.20.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {},
"Labels": {}
}
]
I’ve added php-fpm container to network manually using command “docker network connect mailcow-network mailcowdockerized_php-fpm-mailcow_1”
andrii@andrii-MS-7B33:~/IdeaProjects/Infrastructure/mailcow/mailcow-dockerized$ docker network inspect mailcow-network
[
{
"Name": "mailcow-network",
"Id": "d47a599e70311a42adc06eae5e4cbd190f342d3231698ff5aa3b4690e434e94d",
"Created": "2024-08-19T19:25:31.808137982Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.20.0.0/16",
"Gateway": "172.20.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"7e1779ded75cc04ec3a9eeac4c0028de133373612df0fb7f830cbfa5c5e4f7de": {
"Name": "mailcowdockerized_php-fpm-mailcow_1",
"EndpointID": "abb8ace28d3fe4aecb1997cb434fc375eae7f9f29231d946c71f4be477fbc4f6",
"MacAddress": "02:42:ac:14:00:02",
"IPv4Address": "172.20.0.2/16",
"IPv6Address": ""
},
"c5fef02228420a5547f0443ede4d106f7aac97bd4a1ac5a7de41f7a80646abd8": {
"Name": "mailcowdockerized_nginx-mailcow_1",
"EndpointID": "d9e271a1d1898a4da190c22ca9b1e737d5848a7668c8c7456923f435deb4c200",
"MacAddress": "02:42:ac:14:00:03",
"IPv4Address": "172.20.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
but still got the same error in logs.
I’ve also tried to update NGINX settings to add line:
proxy_pass http://php-fpm-mailcow:9000/;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name mail.somedomain.ua autodiscover.* autoconfig.*;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name mail.somedomain.ua autodiscover.* autoconfig.*;
ssl_certificate /etc/ssl/mail/cert.pem;
ssl_certificate_key /etc/ssl/mail/key.pem;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_session_tickets off;
# See https://ssl-config.mozilla.org/#server=nginx for the latest ssl settings recommendations
# An example config is given below
ssl_protocols TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5:!SHA1:!kRSA;
ssl_prefer_server_ciphers off;
location /Microsoft-Server-ActiveSync {
proxy_pass http://127.0.0.1:8080/Microsoft-Server-ActiveSync;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 75;
proxy_send_timeout 3650;
proxy_read_timeout 3650;
proxy_buffers 64 512k; # Needed since the 2022-04 Update for SOGo
client_body_buffer_size 512k;
client_max_body_size 0;
}
location / {
proxy_pass http://php-fpm-mailcow:9000/;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 0;
# The following Proxy Buffers has to be set if you want to use SOGo after the 2022-04 (April 2022) Update
# Otherwise a Login will fail like this: https://github.com/mailcow/mailcow-dockerized/issues/4537
proxy_buffer_size 128k;
proxy_buffers 64 512k;
proxy_busy_buffers_size 512k;
}
}
but still got errors
for NGINX:
2024-08-22 23:31:05 2024/08/22 23:31:05 [error] 20#20: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.20.0.1, server: mail.somedomain.ua, request: "GET / HTTP/2.0", upstream: "http://172.22.1.7:9000/", host: "mail.somedomain.ua"
for acme:
2024-08-22 23:10:10 Thu Aug 22 23:10:10 EEST 2024 - Initializing, please wait...
2024-08-22 23:10:11 Thu Aug 22 23:10:11 EEST 2024 - Using existing domain rsa key /var/lib/acme/acme/key.pem
2024-08-22 23:10:11 Thu Aug 22 23:10:11 EEST 2024 - Using existing Lets Encrypt account key /var/lib/acme/acme/account.pem
2024-08-22 23:10:11 Thu Aug 22 23:10:11 EEST 2024 - Detecting IP addresses...
2024-08-22 23:10:20 Thu Aug 22 23:10:20 EEST 2024 - OK: 188.239.100.183, 0000:0000:0000:0000:0000:0000:0000:0000
2024-08-22 23:10:32 Thu Aug 22 23:10:32 EEST 2024 - No A or AAAA record found for hostname mail.somedomain.ua
2024-08-22 23:10:32 Thu Aug 22 23:10:32 EEST 2024 - Cannot validate any hostnames, skipping Let's Encrypt for 1 hour.
2024-08-22 23:10:32 Thu Aug 22 23:10:32 EEST 2024 - Use SKIP_LETS_ENCRYPT=y in mailcow.conf to skip it permanently.
And there are several questions:
- Why containers are not available in mailcow docker network?
- Why access through localhost and through domain name is blocked by NGINX?