maxpozdeev / mytinytodo

Todo list script
156 stars 49 forks source link

v1.7.x dont work after fresh install or update on NGINX #45

Closed LiloBzH closed 1 year ago

LiloBzH commented 1 year ago

Hi

a re open a ticket Y tried update or fresh install => same issue

2022-11-03_15-06-57_4ab8d673-a775-40cc-8c6b-12ba589cad44

I dont see any error. Debug mode ?

NGINX with PHP Version 8.1

weird

maxpozdeev commented 1 year ago

To get more debug info you can edit the line 24 in init.php in the root, set this: define('MTT_DEBUG', true);

By clicking on top red error you should see a details.

maxpozdeev commented 1 year ago

Do you use SSL in nginx? If yes, Do you send any flag about https with fastcgi?

LiloBzH commented 1 year ago

With MTT_DEBUG, In "SHOW DETAILS", i have all HTML code of index Page. 0 error.

My Conf NGINX is really classic i think :

server {

listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name todo.mondomaine.ovh;

ssl_certificate /etc/letsencrypt/live/mondomaine.ovh/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mondomaine.ovh/privkey.pem;

include conf.maison/code_ssl_lets_encrypt;

access_log /var/log/nginx/todo.mondomaine.ovh-access.log;
error_log /var/log/nginx/todo.mondomaine.ovh-error.log;

root   /var/www/mondomaine.ovh/todo.mondomaine.ovh/;

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

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/var/run/php8.1-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
                fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
                include fastcgi_params;
        }

}
LiloBzH commented 1 year ago

It's not probably a PHP error. I have no log in Error nginx

maxpozdeev commented 1 year ago

If you see the sources of home page in details I think this is a try_files directive work, api url not found. Try to manually open api url in browser like: /api.php/foo You should see: Unknown command . This means php is ok.

maxpozdeev commented 1 year ago

api.php requires PATH_INFO, please add fastcgi_param PATH_INFO $fastcgi_path_info; to nginx config.

LiloBzH commented 1 year ago

https://todo.mld.ovh/api.php/foo => Show INDEX.PHP

so that's probablement the problem ?

maxpozdeev commented 1 year ago

https://todo.mld.ovh/api.php/foo => Show INDEX.PHP

so that's probablement the problem ?

Yes, this the issue

maxpozdeev commented 1 year ago

This is how I set up nginx:

  location / {
    try_files $uri $uri/ =404;
  }

  location ~ [^/]\.php(/|$) {

    fastcgi_split_path_info ^(.+?\.php)(/.*)$;
    if (!-f $document_root$fastcgi_script_name) {
      return 404;
    }
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO       $fastcgi_path_info;
    fastcgi_index index.php;
    fastcgi_pass  fpm;
  }

  location /db/ {
    return 404; #deny all
  }

  location /includes/ {
    return 404; #deny all
  }

  location ~ /\.ht {
    return 404; #deny all
  }
LiloBzH commented 1 year ago

ahh well done ...

NGINX configuration is a mystery to me sometimes.

maxpozdeev commented 1 year ago

Required changes in your config: location ~ [^/]\.php(/|$) and fastcgi_param PATH_INFO $fastcgi_path_info;