So, by setting the FastCGI path to the absolute file path, you’re effectively turning off FastCGI forwarding for any request that doesn’t start with /home/giuseppe/Sito/Hierarchy/.
This explains why, when set this way, a request for /index.php returns the file unprocessed - the request is being handled by Caddy’s static file server and the file is simply being sent as-is.
Essentially, you’re looking in the wrong ballpark for the solution to this problem. My strong suggestion is to revert back to the simpler fastcgi / /run/php-fpm/php-fpm.sock php (using the php preset here does the exact same as setting ext, split, and index manually).
Now, regarding the 404s… On a hunch, I’d wager that Caddy isn’t actually the culprit here, since PHP-FPM will return 404s for files it can’t access. I’d be looking into permissions (Which user runs Caddy? Which user runs PHP-FPM? Can the files have read-access available to both?).
First of all, I resolved this problem uninstalling caddy and php-fpm, using php built in web server and getting SSL with stunnel. Now I get https on localhost.
Anyway, as I already said, I tried to set the option you mentioned, but I can’t even see the html page. The only way I can see something is with the configuration I posted in the open post, but php code is still not parsed.
I tried everything, both running caddy from root or my user. php-fpm listen to the socket with http user, buy I also tried to set my user, the result is the same.
http user could not have access to my files, but my user can.
To clarify, the configuration you posted, for a request to /index.php, is identical to not having fastcgi in your Caddyfile at all. You can remove it and see for yourself, it will have the same behaviour (you’ll get the raw index.php).
Caddy can already read the file - it does so when you disable FastCGI for /index.php and Caddy serves it unprocessed.
You need to either change PHP-FPM to run as another user that already has read permissions, or you need to change the files so they are readable by your http user.
Caddy configuration changed as you said and php-fpm listening with my user. php-fpm has to be started as root, can’t be started as normal user, but listening socket wil run as http (or with a custom user, I set it as my user). Nothing changed.
I don’t know what to do. Never mind, I will use stunnel.