IP address of fastcgi server?

Ilan Berkner iberkner at gmail.com
Tue Oct 12 14:53:32 MSD 2010


Someone else suggested:

fastcgi_param UPS_SERVER_ADDR $upstream_addr;

and get $_SERVER["UPS_SERVER_ADDR"].

?


On Tue, Oct 12, 2010 at 2:26 AM, Maxim Dounin <mdounin at mdounin.ru> wrote:

> 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 at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101012/3f905eb4/attachment.html>


More information about the nginx mailing list