Nginx + fastcgi php-fpm: address IP

Hello !

I’ve been struggling with that for a few hours now…

I’m using nginx + fastcgi (php-fpm).

Everything works fine, except it seems like it can’t resolve the client IP address.
Instead, it just display in the dashboard.

I tried to change several stuff in my nginx configuration but still can’t make it work.

I’m sure I’m missing something super easy… but what ?

Any help would be appreciated!

please see: Installation - Analytics Platform - Matomo

try adding all lines to your config files (uncommented)


Thank you but I already tried that…

I tried to had a phpinfo() page and the remote address is well passed.
Plus, in the dashboard, the ISP is properly guessed. Which means piwik gets the IP address, but still displays

Do you have another idea ?

Regards !

If piwik displays 0 it shows the IP is not recorded correctly - please check in the log_visit table for the location_ip field?


Looks like an encoding problem ?!

| location_ip |
| X{ˆÃ |
| X{ˆÃ |
| X{ˆÃ |
| X{ˆÃ |

I don’t get it…

Any clue ?

Well… :frowning:

try <?php var_dump($_SERVER);
in a test.php file

is the IP in a _SERVER value?

if I got right your question: no.
My IP shows up in REMOTE_ADDR

[“REMOTE_ADDR”]=> string(14) “my ip address” [“REMOTE_PORT”]=> string(5) “53446”

Is that what you meant ?

Piwik looks in REMOTE_ADDR to get the IP so maybe try to remove the proxy config from your config.ini.php ?

it should work

There’s not particular config about proxy in my config.ini.php.

And, sorry if I wasn’t clear enough: REMOTE_ADDR IS the right IP address (the client one, not the server one).
That’s what I meant by “my IP address”.

When u asked me to look what was stored in the database, did u see my answer?
It looks like an encoding problem or something :confused:

up ?

mysql> SELECT INET_NTOA(location_ip) from piwik_log_visit;
| INET_NTOA(location_ip) |
| |
| |
| |
| |

So, no. It’s not an encoding problem.

Any other idea ?

Sounds like You need to install the nginx real ip module. Are you behind a load balancer?

You need to map the ip to the correct php var in nginx configs.

See Module ngx_http_realip_module

Hello Gmck,

Thanks for your help but I’m not behind a loadbalancer and it’s only not working with Piwik.
As I showed previously in this thread, the IP address seemed to be well passed by nginx (please see the part with the phpinfo() ).

Anything else ?


Please attach your nginx.conf, (and any other fpm conf files) & php.ini files. I can only speculate without seeing the conf files.


Sorry for the delay. I’ve been pretty busy the past few days.

You can find the files you asked for at the following:

Let me know if u need anything else.


up ! :slight_smile:

up ?

There is nothing in the config files that jumps out as being a problem. If your web server logs are showing the client IP address, then it’s happening at the javascript level where Piwik is not getting the IP passed to it.