We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

nginx routing problem

Hi! I've just uploaded my website to remote nginx-based system and my routing simply does not work. All page links gos to main page (seems like nothing happens and nothing routed). I've tried all nginx configs which are in documentation with no luck. There are no errors in logs. baseUri settings didn't help also. What's wrong?

I am working only with nginx, and everything works ok. Check my config:

server {
        server_name domain.tld;
        root /home/domain.tld/public;
        index index.php index.html index.htm;

        error_log /home/domain.tld/error.log;

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

        location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/home/domain.tld/domain.tld.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param PHP_VALUE "open_basedir = /home/domain.tld:/tmp";
        }
}

php-fpm pool

[domain.tld]
listen = /home/domain.tld/domain.tld.sock
user = www-data
group = www-data
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 4
chdir = /

$router.php

$router = new Phalcon\Mvc\Router();

$router->setUriSource(\Phalcon\Mvc\Router::URI_SOURCE_SERVER_REQUEST_URI);

$router->removeExtraSlashes(true);
$router->setDefaultController('index');
$router->setDefaultAction('index');

return $router;

I have just added my $router.php to my last post



7.0k

Seems you do not have correct configuration in your nginx setting. Paste your nginx server block.

I have exactly the same config as posted in docs (tried all of them). Now I temporarily use Apache but it seems I need to set up 'setUriSource'. I will try to check this when I reach my server next time.