I need help to run EspoCRM using Caddy server

1. The problem I’m having:

Hi everyone,

I’m new to using Caddy and would like some help. I’m trying to set up EspoCRM to run on a Caddy localhost server using ServBay, but I’m having trouble converting my Nginx configuration to a CaddyFile.

Could someone help me with the conversion or provide guidance on any Caddy specifics I should consider for this setup? Any advice would be much appreciated!

Thank you!

Nginx config:

Here is the Nginx config:

    location /client {
        root /path-to-espo; # path to espocrm root dir
        autoindex off;

        location ~* ^.+\.(js|css|png|jpg|svg|svgz|jpeg|gif|ico|tpl)$ {
            access_log off;
            expires max;
        }
    }

    location ~ \.php$ {
        fastcgi_pass espocrm-php:9000;
        include fastcgi_params;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param QUERY_STRING $query_string;
    }

    location /api/v1/ {
        if (!-e $request_filename){
            rewrite ^/api/v1/(.*)$ /api/v1/index.php last; break;
        }
    }

    location /portal/ {
        try_files $uri $uri/ /portal/index.php?$query_string;
    }

    location /api/v1/portal-access {
        if (!-e $request_filename){
            rewrite ^/api/v1/(.*)$ /api/v1/portal-access/index.php last; break;
        }
    }

3. Caddy version:

2.8.4

4. How I installed and ran Caddy:

I am using ServBay

My complete Caddy config:

extension.host {
    encode zstd gzip
    import set-log extension.host

    tls "/Applications/ServBay/ssl/private/tls-certs/extension.host/extension.host.crt" "/Applications/ServBay/ssl/private/tls-certs/extension.host/extension.host.key"

    import canonical-path

    root * "/path-to-espo/public"

    route {
        import php-rewrite-default 8.2
    }

    file_server
}

5. Links to relevant resources:

https://docs.espocrm.com/administration/nginx-server-configuration/#server-configuration

After long research I managed to run it this way:

# extension.host
extension.host {
    encode zstd gzip
    import set-log extension.host

    tls "/Applications/ServBay/ssl/private/tls-certs/extension.host/extension.host.crt" "/Applications/ServBay/ssl/private/tls-certs/extension.host/extension.host.key"

    import canonical-path

    handle_path /client* {
        root * /Users/eymenelkum/Work/CRMProjects/crm-extensions/client
    }

    handle_path /api/v1/* {
        try_files {path} /api/v1/index.php
    }

    handle_path /portal/* {
        try_files {path} {path}/ /portal/index.php?{query}
    }

    handle_path /api/v1/portal-access/* {
        try_files {path} /api/v1/portal-access/index.php
    }

    root * "/Users/eymenelkum/Work/CRMProjects/crm-extensions/public"

    route {
        import php-rewrite-default 8.2
    }

    file_server
}
1 Like

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