Skip to content

fpm: Implement access log filtering #8214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

maaarghk
Copy link
Contributor

@maaarghk maaarghk commented Mar 17, 2022

Fixes GH-8174, #80428

Before merging I think it could be doing with more tests:

  • check the config parser fails in sensible ways
  • check the config dumper outputs what it is supposed to
  • check the request method / body filtering works

@bukka
Copy link
Member

bukka commented Mar 23, 2022

From the very quick look, it's looking good. I was initially thinking something more in line with listen.allowed_clients but this is actually nicer IMO.

@maaarghk
Copy link
Contributor Author

@bukka do you happen to have any POST-doing tester.inc versions lying around somewhere to save me a bit of time?

@bukka
Copy link
Member

bukka commented Mar 25, 2022

do you mean something like

$tester->request('', ['REQUEST_METHOD' => 'POST'])->expect...

@maaarghk maaarghk force-pushed the fpm-access-exclude branch 2 times, most recently from 03dcddd to c042a61 Compare March 29, 2022 00:10
@maaarghk
Copy link
Contributor Author

nah I meant actually passing STDIN, wasn't too hard to work out anyway so just pushed it up and think I'm done with this

@maaarghk maaarghk requested a review from bukka March 29, 2022 12:42
@maaarghk
Copy link
Contributor Author

maaarghk commented Apr 3, 2022

Just popped into my head here whilst thinking about something unrelated, but - since proc->request_uri actually gets set to script_name, because that is what's read into PHP_SELF sapi->register_variables - is it the right thing to check? I know at least on servers I admin I put %{REQUEST_URI}e in the access.format for this reason. From the perspective of fpm_log.c should %r / request uri be redefined from proc.request_uri to coalesce(fcgi_getenv(REQUEST_URI), proc.request_uri)? Could be overthinking it of course. Probably makes sense for health check scripts to be separate PHP files that don't go through routers and whatever anyway.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good.

@bukka
Copy link
Member

bukka commented Apr 6, 2022

Just popped into my head here whilst thinking about something unrelated, but - since proc->request_uri actually gets set to script_name, because that is what's read into PHP_SELF sapi->register_variables - is it the right thing to check? I know at least on servers I admin I put %{REQUEST_URI}e in the access.format for this reason. From the perspective of fpm_log.c should %r / request uri be redefined from proc.request_uri to coalesce(fcgi_getenv(REQUEST_URI), proc.request_uri)? Could be overthinking it of course. Probably makes sense for health check scripts to be separate PHP files that don't go through routers and whatever anyway.

I would probably default to request_uri as it might be better to later add another option to specify path pattern where it could be possible to set how to get the path in a similar way like it is for the actual log pattern.

@maaarghk maaarghk force-pushed the fpm-access-exclude branch from c042a61 to 1cffae6 Compare April 6, 2022 15:21
@ramsey ramsey added this to the PHP 8.2 milestone May 25, 2022
@bukka
Copy link
Member

bukka commented Jun 29, 2022

@maaarghk Just a reminder that a feature freeze is on 5th July so it would be good to add this potentially. The comments are just NIT's so will try to give it a try over the weekend and see if we can merge it and I can additional fix them possibly. Although if you want to fix them before that, it would be appreciated!

@maaarghk maaarghk force-pushed the fpm-access-exclude branch from 1cffae6 to 24f81b2 Compare July 1, 2022 00:46
@github-actions github-actions bot removed the SAPI: fpm label Jul 1, 2022
@maaarghk
Copy link
Contributor Author

maaarghk commented Jul 2, 2022

@bukka I noticed the bot removed SAPI: fpm label from this, just flagging it incase that makes it drop off your radar

@bukka
Copy link
Member

bukka commented Jul 2, 2022

Thanks, bot should be now fixed. Will try to give it a try tomorrow.

@bukka
Copy link
Member

bukka commented Jul 2, 2022

If you could squash it to a single commit in the meantime, that would be great!

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the changes and all looks good to me. Just added few minor suggestions that you are free to ignore if you are too busy. I will merge it in the next few days.

@bukka
Copy link
Member

bukka commented Jul 3, 2022

One correction that the feature freeze is actually on 19th. I confused it with a deadline for RFCs so there is a bit more time.

Adds a setting "access.suppress_path" to php-fpm pool configurations
which causes successful GET requests to the specified URIs to be
excluded from the access log. This is to reduce noise caused by
automated health checks.

Requests with response codes outwith the successful range 200 - 299,
requests made with query parameters and requests which have a
Content-Length other than 0 will ignore this setting as a security
precaution.

Closes phpGH-8174, #80428 [1]

[1] https://bugs.php.net/bug.php?id=80428
@maaarghk maaarghk force-pushed the fpm-access-exclude branch from 24f81b2 to 2ecc7ca Compare July 4, 2022 12:47
@bukka
Copy link
Member

bukka commented Jul 10, 2022

Merged in 327bb21 . Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP-FPM : Option to suppress "/ping" from logs -- patch file given
3 participants