So I did some more digging, and between some chatbots, some coding, and most importantly some comments squirreled away deep inside a stack overflow discussion, re-reading the php settings thing in Plesk, and realizing some different problem may be related: See this comment:
This answer hit the nail in the head. Sometimes it's not just the configuration of nginx, but what's actually producing the header. When error_reporting contains the notices but display_errors is off in php.ini, all the messages show up in FCGI header instead of content.
My other existing issue is documented here:
Is there a guide on setting up php-fpm to log to its client log in their log folder? I've had a few clients who had the warning deprecation log flood caused by the actual site's code; nothing php.ini had control over growing into huge multi-GB files. 1) I want these log files in the client's...
talk.plesk.com
I'm still seeing the same thing. There's the nginx error logs in the domain, but that doesn't contain the FPM log. FPM throws everything and the kitchen sink into one giant file at /var/log/plesk-php83-fpm/error.log.*, when what I want is a log file
per domain as the starting point. I don't need FPM to forward PHP errors to nginx through a mousehole and nginx then printing them, just for those errors to be accessible to the site owner.
There's this topic here that points to some info:
https://serverfault.com/questions/1193464/per-domain-error-log-for-php-fpm-and-apache
But this is for a regular linux server... not one with the quite complicated plesk program stuffed over top. Going "around" plesk to the backend and directly hacking something up is just going to result in a bunch of pain later when things get overwritten/changed by updates or restarts, so I need a way to properly set error logs (iff indeed this is the problem, which I think is pretty likely at this point) in a way that is reasonable.
I think what may be happening is that certain kinds of PHP errors, including warnings related to attempting to access files outside of the site path (wordpress plugins doing stupid things) ...
are being sent into the PHP-FPM header buffer somehow.
Which is an incredibly stupid thing to do, as that buffer is positively
tiny. Any kind of PHP warning or error that wordpress generates is incredibly verbose, I've seen megabytes be produced by a single request with ease before via 'security plugin' databases spewing banlist data all over traces and what not. Why would it do that? Why not write to a log file and call it a day? Can I set it up to be... not
utterly insane, please?
Here's the conditions I'd like to fulfill:
* Yes, I do want per-domain logs. Site owners may actually fix things if they're presented with a slew of errors rather than them getting blackholed out of view.
* No, do not display all the errors and warnings on-screen to all site visitors.
* Standard level I've set is fine (E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED)
* Keep using Nginx/FPM as it's the most modern/fastest way of serving PHP. I'm otherwise happy with this way of organizing the web stack.
* Don't put the error log for a request in a 32 KILOBYTE buffer. No, my elephant of an error can't fit through that mousehole.
* Do it via plesk or plesk cli so plesk won't ruin the setup with the next update.
* An explanation as to why and how it works rather than cargo-cult copying working but fragile settings is more useful for people in the future.
As the problem is squirrelled away somewhere in the closed-encrypted-source thing that's generating PHP settings files with wrong log configurations I need some help with this. To do, according to the quote;
So I believe the correct answer is: fix your fpm config so it logs errors to disk.
I found where plesk actually stores the output file I want changed, in /opt/plesk/php/8.x/etc/php-fpm.d/. These files look like (red.)
Code:
; ATTENTION!
;
; DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
; SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
; If you need to customize this file, use either custom PHP settings tab in
; Panel or override settings in /var/www/vhosts/system/ims.acme.com/conf/php.ini.
; To override pool configuration options, specify them in [php-fpm-pool-settings]
; section of /var/www/vhosts/system/ims.acme.com/conf/php.ini file.
[ims.acme.com]
; Don't override following options, they are relied upon by Plesk internally
prefix = /var/www/vhosts/system/$pool
user = bressernu
group = psacln
listen = php-fpm.sock
listen.owner = root
listen.group = psaserv
listen.mode = 0660
; Following options can be overridden
chdir = /
; If php_value[error_log] is not defined, worker errors will be sent to
; web server and main php-fpm error log
catch_workers_output = yes
; php.ini custom configuration directives
php_admin_value[disable_functions] = "opcache_get_status"
php_value[error_reporting] = 22519
php_admin_value[max_execution_time] = 30
php_admin_value[max_input_time] = 60
php_admin_value[memory_limit] = 128M
php_value[open_basedir] = "/var/www/vhosts/acme.com/:/tmp/"
php_admin_value[post_max_size] = 8M
php_admin_value[upload_max_filesize] = 8M
; Following directives define pool configuration
pm = ondemand
pm.max_children = 5
pm.max_requests = 0
pm.max_spare_servers = 1
pm.min_spare_servers = 1
pm.process_idle_timeout = 10s
pm.start_servers = 1
The problem is there's no value generated there for the log file. There's specifically a missing generated line that should look like this;
Code:
php_admin_value[error_log] = "/var/www/vhosts/acme.com/logs/ims.acme.com/php-error.log"
Without that, it's trying to put it through a buffer that was never created to handle that much data. Just a few cookies.
Now the main question: After I think I've figured out the cause... How do I get that in there? Why's plesk not putting that in there? And also stop the existing log path forwarding it to nginx, I'm fine with the nginx error log only having nginx errors and the php(fpm) errors in two locations rather than being 4-5x duplicated; one in /var/www/vhosts/system/$hostname/logs, and the other one a symlink there.
There should be two levels though as I don't want the site owner being able to alter the logs I see as admin. Just to view them from within Plesk.