Welcome! Log In Create A New Profile

Advanced

Re: IP address of fastcgi server?

Maxim Dounin
October 12, 2010 02:30AM
Hello!

On Mon, Oct 11, 2010 at 09:41:32PM -0400, Ilan Berkner wrote:

> Hi All,
>
> We're doing some profiling and one of the parameters we'd like to get is the
> IP address of the fastcgi (in this case php-fpm) server that processed the
> request. PHP $_SERVER['server_addr'] returns the external address of the
> nginx server per our fastcgi configuration:
>
> fastcgi_param SERVER_ADDR $server_addr;
>
> Is this correct behavior? is there a way to get the local address of the
> server processing the php request?

Yes, SERVER_ADDR is expected to contain http server address, not
the address of fastcgi application.

Moreever, upstream's address (fastcgi application address in your
case) isn't available when nginx creates request to upstream (as
particular upstream server isn't selected yet, and even after
selection it may change due to proxy_next_upstream).

You should be able to find out fastcgi application's address in
fastcgi application itself, it's just a matter of calling
getpeername() on connection socket. Not idea how to do it in php
though.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

IP address of fastcgi server?

iberkner October 11, 2010 09:46PM

Re: IP address of fastcgi server?

Maxim Dounin October 12, 2010 02:30AM

Re: IP address of fastcgi server?

iberkner October 12, 2010 06:58AM

Re: IP address of fastcgi server?

Maxim Dounin October 12, 2010 07:08AM

Re: IP address of fastcgi server?

hobson42 October 12, 2010 03:06PM

Re: IP address of fastcgi server?

iberkner October 12, 2010 03:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 193
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