Skip to content

Redirect HTTP to HTTPS

If you are using a reverse proxy in front of mailcow, please see our reverse proxy guide for this, which includes a redirect from HTTP to HTTPS.

Open mailcow.conf and set HTTP_BIND= - if not already set.

Version >= 2025-01a

Open mailcow.conf and set HTTP_REDIRECT=y.
Recreate the container:

docker compose up -d
docker-compose up -d

Version < 2025-01

Since February the 28th 2017 mailcow does come with port 80 and 443 enabled.

Create a new file data/conf/nginx/redirect.conf and add the following server config to the file:

server {
  root /web;
  listen 80 default_server;
  listen [::]:80 default_server;
  include /etc/nginx/conf.d/server_name.active;
  if ( $request_uri ~* "%0A|%0D" ) { return 403; }
  location ^~ /.well-known/acme-challenge/ {
    allow all;
    default_type "text/plain";
  }
  location / {
    return 301 https://$host$uri$is_args$args;
  }
}

In case you changed the HTTP_BIND parameter, recreate the container:

docker compose up -d
docker-compose up -d

Otherwise restart Nginx:

docker compose restart
docker-compose restart