phpnginxnginx-configcodeigniter-4vtiger

CodeIgniter 4-Nginx Server 404


I'm trying to make a website with VTiger using CodeIgniter 4, Composer with MySQL database

I made the installation following the instructions in CodeIgniter documentation, but I can't find the error. The problem is when I enter into the login page (this page works) and I write my access that is working because I don't get a bad credentials error. The website just shows me 404, previously I was getting 401 Unauthorized, but that changed when I edited my nginx conf file.

This is my nginx .conf file

server {
    root /var/www/html/mydomain.com/;
    error_log /var/log/nginx/mydomain.com.error.log debug;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php;
    server_name mydomain.com;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\. {
        deny all;
    }

    listen [::]:443 ssl http2; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; # managed by Certbot
    #include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    #ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    }

    server {
        if ($host = mydomain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    server_name mydomain.com;
    listen [::]:80;
    listen 80;
    # return 404; # managed by Certbot
    }

I checked necessary extensionsfor PHP, here my php info PHP INFO

I know it's really hard find the issue, but maybe someone with more experience can help to fix it or to know where can I start If you need more info about my config, please let me know


Solution

  • I was able to solve it on my own, after researching I found that unlike Apache, the routing configuration must be done manually for Nginx

    location /vtigerest/ {
                alias /var/www/html/mydomain.com/vtigerest/;
                try_files $uri $uri/ /vtigerest/index.php;
    
        # pass PHP scripts to FastCGI server
        #
            location ~ \.php$ {
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_index index.php;
                    include /etc/nginx/fastcgi_params;
                    include snippets/fastcgi-php.conf;
                    fastcgi_pass unix:/run/php/php8.2-fpm.sock;
                    fastcgi_param SCRIPT_FILENAME $request_filename;
            }
        }