N
N
nikolayvaganov2016-04-28 10:07:56
PHP
nikolayvaganov, 2016-04-28 10:07:56

How to achieve logging REMOTE_ADDR in access.log for fpm unix socker + nginx?

Hello,
I've been struggling with the issue of logging visitor addresses in access.log fpm for some time now.
Now nginx + fpm is connected as unix socket. Everything works fine, only the visitor's IP address is not transmitted to access.log, although when executing this code on the site: The address is displayed correctly. In the log instead of the address like this:
<?php echo $_SERVER['REMOTE_ADDR']; ?>
- - 28/Apr/2016:10:00:53 +0300 "GET /i.php

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lynn "Coffee Man", 2016-04-28
@nikolayvaganov

Try adding it %{REMOTE_ADDR}eto access.format
Found here https://gist.github.com/fprochazka/1853008#file-ph...
and in the PHP sources git.php.net/?p=php-src.git;a=blob ;f=sapi/fpm/fpm/f...

D
Dimonchik, 2016-04-28
@dimonchik2013

something like this
https://support.cloudflare.com/hc/en-us/articles/2...
but one nginx is not enough, if fpm does not pass it in any way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question