getting remot4e address
rkmr.em at gmail.com
rkmr.em at gmail.com
Wed Feb 27 00:38:20 MSK 2008
On Tue, Feb 26, 2008 at 1:24 PM, Igor Sysoev <is at rambler-co.ru> wrote:
>
> On Tue, Feb 26, 2008 at 01:11:40PM -0800, rkmr.em at gmail.com wrote:
>
> > On Tue, Feb 26, 2008 at 1:00 PM, Igor Sysoev <is at rambler-co.ru> wrote:
> > > On Tue, Feb 26, 2008 at 12:52:56PM -0800, rkmr.em at gmail.com wrote:
> > > > On Tue, Feb 26, 2008 at 12:08 PM, Igor Sysoev <is at rambler-co.ru> wrote:
> > > > > On Tue, Feb 26, 2008 at 11:58:16AM -0800, rkmr.em at gmail.com wrote:
> > > > >
> > > > > > x-forwarded-for enabled in the haproxy configuration.
> > > > > > How do I configure nginx so that my fastcgi backends get this IP
> > > > > > address as the remote ip address and not the ip address of the
> > > > > location / {
> > > > > set $addr $remote_addr;
> > > > >
> > > > > if ($http_x_forwarded_for ~ "(^|,)\s*(\d+\.\d+\.\d+\.\d+)\s$") {
> > > > > set $addr $1;
> > > > > }
> > > > >
> > > > > ...
> > > > > fastcgi_param REMOTE_ADDR $addr;
> > > >
> > > > hi igor,
> > > > thanks for your reply.
> > > > i tried what you gave, and i still get only the ip address of the
> > > > haproxy in my backends,
> > > My mistake:
> > >
> > > - if ($http_x_forwarded_for ~ "(^|,)\s*(\d+\.\d+\.\d+\.\d+)\s$") {
> > > + if ($http_x_forwarded_for ~ "(^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$") {
> >
> > igor:
> > now for ip in the fastcgi backend i get an empty string
> > 'ip': ''
> >
> > current config:
> > set $addr $remote_addr;
> > if ($http_x_forwarded_for ~ "(^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$") {
>
> - if ($http_x_forwarded_for ~ "(^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$") {
> + if ($http_x_forwarded_for ~ "(?:^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$") {
>
> > set $addr $1;
works great now!!!
here is the final config:
set $addr $remote_addr;
if ($http_x_forwarded_for ~ "(?:^|,)\s*(\d+\.\d+\.\d+\.\d+)\s*$") {
set $addr $1;
}
thanks a lot
More information about the nginx
mailing list