Nginx rewrite with Phalcon in subfolder and many phalcon projects

Hi, im with problem for configure Nginx with Phalcon in subfolder and many phalcon projects.

Phalcon is in / var/etc/cmphalcon, being public in /var/www/cmphalcon/public.

When you enter the address mysite.com/cmphalcon, load this application and when it is another address, will load another Phalcon project.

Current setting:

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

location @phalcon {
    rewrite ^/cmphalcon/public(.+)$ /cmphalcon/public/index.php?_url=$1 last;
}

location /cmphalcon/ {
    index index.php;
    if ($uri !~ ^/cmphalcon/public) {
        rewrite ^/cmphalcon(.*)$ /cmphalcon/public$1;
    }
    try_files $uri $uri/ @phalcon;
}

It has worked, but it is with the / at the end of the address, generating in the internal links of the application //, I would like help in the configuration and if it has how to remove the / final that is in the URL.

Thankful, Felipo Antonoff.

Thanks for the answer.

We currently use the:

// Remove trailing slashes automatically
$router->removeExtraSlashes(true);

If we use direct in the domain or subdomain without subfolder, it works.

But when we try to use the application subfolder, it gets the / at the end of the URL and thus generates links with two /.

This native Phalcon configuration worked well for subdomain:

root /var/www/cmphalcon/public;
    index index.php index.html index.htm;

location /{
        try_files $uri $uri/ /index.php?_url=$uri&$args;
}