IredMail with Caddy

Heyo, i have a email server using IRedMail. which by default, uses Nginx. the first chunk of the config is simple and can be ported, i just dont know the equivilant of Nginx’s include config for caddy

 #Note: This file must be loaded before other virtual host config files,
 #
 # HTTPS
 server {
 listen 443;
 server_name _;

 root /var/www/html;
 index index.php index.html;

 include /etc/nginx/templates/misc.tmpl;
 include /etc/nginx/templates/ssl.tmpl;
 include /etc/nginx/templates/iredadmin.tmpl;
 include /etc/nginx/templates/roundcube.tmpl;
 include /etc/nginx/templates/sogo.tmpl;
 include /etc/nginx/templates/netdata.tmpl;
 include /etc/nginx/templates/php-catchall.tmpl;
 }

Hi @Merith-TK, welcome to the Caddy community.

nginx’s include reads additional nginx configuration files into the current configuration. It is identical in purpose to Caddy’s import directive.

https://caddyserver.com/docs/import

Files nominated by include also need to be valid nginx configuration, so they will need to be translated as well while you’re converting to Caddyfile configuration.

Alright, thanks, Im trying to convert a whole lot of NGINX configuration files to caddy so i can use my email server with Caddy.

Alot of it, i have no clue what alot of the stuff is,
Would you or a community member help me learn how to convert the files over?

Okay, what is the caddy equivilant of this?
# static files under /iredadmin/static
location ~ ^/iredadmin/static/(.*) {
alias /opt/www/iredadmin/static/$1;
}

this is NGINX configurations

About as often as there is a direct translation, there’s no direct translation but other ways to achieve the underlying goal of the configuration.

In this case, the configuration is set to have /iredadmin/static serve files from disk from /opt/www/iredadmin/static. You can do this in Caddy with another path-specific virtual host:

example.com/iredadmin/static {
  root /opt/www/iredadmin/static
}

It’s not entirely the same - it doesn’t go within another block like nginx’s probably would, it stands on its own in the Caddyfile - but it should achieve the same purpose.

Well ive actually minimized everything to the bare essentials for the email server (no iredadmin tho)

Now im having a php issue…and its annoying
essentially PHP7.0-FPM is denying access to ANYTHING

this is the error

21/Dec/2018:04:29:57 +0000 [ERROR 502 /] dial unix /run/php/php7.0-fpm.pid: connect: connection refused

EDIT:
If i can get the main Email page mydomain.com/email to load without giving me a 502 i will beable to work on the other panel

Why are you trying to dial /run/php/php7.0-fpm.pid? What’s your Caddyfile look like at the moment?

I have fixed my php issue, but now im getting a redirect loop.
Ive noticed Caddy does this when using Proxy with a website that uses caddy

current caddy config on the Router Server (routes traffic)

box.merith.tk {
    proxy / 192.168.0.131 {
    transparent
    }

    log /var/log/caddy/mail.log
    errors /var/log/caddy/errors.log               
}

IRedMail server

:80 {
        root /opt/www/roundcubemail
        index index.php

        log /etc/caddy/caddy.log
        errors /etc/caddy/errors.log

        #PHP-FPM Configuration for Caddy
        fastcgi / 127.0.0.1:9999 {
                ext .php
                split .php
                index index.php
        }
}

To see what my issue is, go to
https://box.merith.tk

1 Like

I’m getting a good response from that website - a HTTP 200 OK, with two Server: Caddy headers (indicating that there’s a Caddy proxying another Caddy currently).

i actually fixed it, appearntly, the index.php had some code that was redirecting to https, but i had the caddy server running on port 80. so it looped over and over, causing a redirect loop.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.