Welcome! Log In Create A New Profile

Advanced

Custom log

Posted by Ali Trix 
Ali Trix
Custom log
June 18, 2013 10:25AM
Hi,

Is it possible to make a custom log with php-fpm where I can add
environment variables?
I ask this, because I want to add the IP of the user which caused the
access/error log.

We run a nginx<->php-fpm combination.
Previously we had apache2 and that showed us the IP of the users on every
access/error line, so we could debug which user caused the Fatal to fix the
bug.

Anyone has experience with php-fpm to fix this issue?

Ali

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Jérôme Loyet
Re: Custom log
June 18, 2013 10:25AM
Hi,

yes %R return the client address of FPM, which means it will log your nginx
IP address, not the IP of the nginx client (the browser).

So for now it's not possible to include in the logs input headers (like
HTTP_X_FORWARDED_FOR). You can use %o{xxxx} for output headers but input
headers are not supported yet. Feel free to publish a patch to fpm_log.c (
https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fpm_log.c)

++ jerome


2013/6/13 Joe <ext@originalmind.com.au>

> Hi Ali,
>
> Have a look at the reference conf file from the source here:
> https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in
>
> I believe %R will work for you, although from memory you need to set up
> the correct fastcgi parameter to get the correct IP through to php.
>
>
> On Wednesday, 12 June 2013 19:37:43 UTC+10, Ali Trix wrote:
>>
>> Hi,
>>
>> Is it possible to make a custom log with php-fpm where I can add
>> environment variables?
>> I ask this, because I want to add the IP of the user which caused the
>> access/error log.
>>
>> We run a nginx<->php-fpm combination.
>> Previously we had apache2 and that showed us the IP of the users on every
>> access/error line, so we could debug which user caused the Fatal to fix the
>> bug.
>>
>> Anyone has experience with php-fpm to fix this issue?
>>
>> Ali
>>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "highload-php-en" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to highload-php-en+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Ali Trix
Re: Custom log
June 18, 2013 10:25AM
Hi Jerome,

I wish my C was that good :(, I know the basics but suck in pointers and
memory managment.
If it was, believe me, I would wirte a patch and publish it!

Ali

Op donderdag 13 juni 2013 11:56:49 UTC+2 schreef Jérôme Loyet het volgende:
>
> Hi,
>
> yes %R return the client address of FPM, which means it will log your
> nginx IP address, not the IP of the nginx client (the browser).
>
> So for now it's not possible to include in the logs input headers (like
> HTTP_X_FORWARDED_FOR). You can use %o{xxxx} for output headers but input
> headers are not supported yet. Feel free to publish a patch to fpm_log.c (
> https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fpm_log.c)
>
> ++ jerome
>
>
> 2013/6/13 Joe <e...@originalmind.com.au <javascript:>>
>
>> Hi Ali,
>>
>> Have a look at the reference conf file from the source here:
>> https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in
>>
>> I believe %R will work for you, although from memory you need to set up
>> the correct fastcgi parameter to get the correct IP through to php.
>>
>>
>> On Wednesday, 12 June 2013 19:37:43 UTC+10, Ali Trix wrote:
>>>
>>> Hi,
>>>
>>> Is it possible to make a custom log with php-fpm where I can add
>>> environment variables?
>>> I ask this, because I want to add the IP of the user which caused the
>>> access/error log.
>>>
>>> We run a nginx<->php-fpm combination.
>>> Previously we had apache2 and that showed us the IP of the users on
>>> every access/error line, so we could debug which user caused the Fatal to
>>> fix the bug.
>>>
>>> Anyone has experience with php-fpm to fix this issue?
>>>
>>> Ali
>>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "highload-php-en" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to highload-php-...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Ali Trix
Re: Custom log
June 18, 2013 10:25AM
Thanks, this helps!

But, this only solves the problem for access log.

Is there a way to do this for the error log as well?

Ali

Op donderdag 13 juni 2013 11:49:09 UTC+2 schreef Joe het volgende:
>
> Hi Ali,
>
> Have a look at the reference conf file from the source here:
> https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in
>
> I believe %R will work for you, although from memory you need to set up
> the correct fastcgi parameter to get the correct IP through to php.
>
> On Wednesday, 12 June 2013 19:37:43 UTC+10, Ali Trix wrote:
>>
>> Hi,
>>
>> Is it possible to make a custom log with php-fpm where I can add
>> environment variables?
>> I ask this, because I want to add the IP of the user which caused the
>> access/error log.
>>
>> We run a nginx<->php-fpm combination.
>> Previously we had apache2 and that showed us the IP of the users on every
>> access/error line, so we could debug which user caused the Fatal to fix the
>> bug.
>>
>> Anyone has experience with php-fpm to fix this issue?
>>
>> Ali
>>
>

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ohm
Re: Custom log
June 18, 2013 10:25AM
Hi Ali,

Have a look at the reference conf file from the source here:
https://github.com/php/php-src/blob/master/sapi/fpm/php-fpm.conf.in

I believe %R will work for you, although from memory you need to set up the
correct fastcgi parameter to get the correct IP through to php.

On Wednesday, 12 June 2013 19:37:43 UTC+10, Ali Trix wrote:
>
> Hi,
>
> Is it possible to make a custom log with php-fpm where I can add
> environment variables?
> I ask this, because I want to add the IP of the user which caused the
> access/error log.
>
> We run a nginx<->php-fpm combination.
> Previously we had apache2 and that showed us the IP of the users on every
> access/error line, so we could debug which user caused the Fatal to fix the
> bug.
>
> Anyone has experience with php-fpm to fix this issue?
>
> Ali
>

--

---
You received this message because you are subscribed to the Google Groups "highload-php-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to highload-php-en+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 223
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready