Welcome! Log In Create A New Profile

Advanced

Re: Real IP not working?

BigdinoWebmaster
December 04, 2011 03:10PM
I've got nginx proxying to a lighttpd server (hosted on a DroboPro FS), and I'm using only the following four directives in the proxy location's stanza:

proxy_pass http://<proxy destination>
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


This seems to be all that's necessary. The proxy target's access log shows the accessing client's IP for each request, not the nginx server.

You've got a lot more stuff going on in your config, though, so I'm not sure if this will be helpful to you or not. Maybe you could comment out some directives and start with just the basics?

-Lee


On Sunday, December 4, 2011 at 1:19 PM, pk899 wrote:
> pk899 Wrote:
> -------------------------------------------------------
> > Alexander Kolesen Wrote:
> > --------------------------------------------------
> > -----
> > ....
> > > in your location section with 'proxy_pass'
> > > directive
> > > (or 'fastcgi_pass' or whatever you use).
> > >
> > > Like the following:
> > >
> > > location / {
> > > ....
> > > proxy_pass
> > > http://<backend_ip>:<backend_port>;
> > > proxy_set_header Host
> > >
> >
> >
> > > $host;
> > > + proxy_set_header X-Real-IP
> > >
> >
> >
> > > $remote_addr;
> > > ....
> > > }
> > >
> > > Your mod_rpaf config have already correctly set
> > up
> > > to handle X-Real-IP header
> > > and consider it as the end user's IP.
> > >
> > > Also, you shouldn't use the RPAFsethostname
> > option
> > > turned 'On' unless you
> > > set X-Host header in the nginx config before
> > > passing request to backend. Just turn it 'Off'.
> > >
> >
> >
> >
> >
> >
> > Thanks Alexander. But this does not work.
> >
> > I commented all the "set_real_ip_from" in nginx
> > config. Restarted nginx.
> >
> > Now the "REMOTE_ADDR" in my php code inside Apache
> > is just my server's IP. So the real IP is not
> > being passed.
> >
> > If I enable the "set_real_ip_from" inside nginx
> > config, then my php code sees the right
> > REMOTE_ADDR. But the log messages inside Apache
> > are wrong even then....all from my own server IP.
> >
> >
> > Anyway, my nginx "proxy.inc" is this:
> >
> >
> > <code>
> > proxy_cache_bypass $http_pragma
> > $http_authorization;
> > proxy_no_cache $http_pragma
> > $http_authorization;
> > proxy_temp_file_write_size 512k;
> > proxy_pass_header Set-Cookie;
> > proxy_redirect off;
> > proxy_hide_header Vary;
> > proxy_set_header Accept-Encoding '';
> > proxy_set_header Referer
> > $http_referer;
> > proxy_set_header Host $host;
> > proxy_set_header Cookie $http_cookie;
> >
> > proxy_set_header X-Real-IP
> > $remote_addr;
> > proxy_set_header X-Forwarded-Host
> > $host;
> > proxy_set_header X-Forwarded-Server
> > $host;
> > proxy_set_header X-Forwarded-For
> > $proxy_add_x_forwarded_for;
> > </code>
> >
> >
> > Any ideas?
> >
> >
> >
> > PS: I turned that RPAFsethostname off in apache.
> > This seems harmless enough.
> >
>
>
>
>
>
>
>
> Btw, just to add...
>
> The HTTP_X_FORWARDED_FOR variable does have the right IP address, but
> the "REMOTE_ADDR" does not. The latter has only my own server IP.
>
> What do I need to do?
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,219581,219595#msg-219595
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org (mailto:nginx@nginx.org)
> http://mailman.nginx.org/mailman/listinfo/nginx
>
>


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

Real IP not working?

pk899 December 04, 2011 10:12AM

Re: Real IP not working?

Alexander Kolesen December 04, 2011 01:38PM

Re: Real IP not working?

pk899 December 04, 2011 02:16PM

Re: Real IP not working?

pk899 December 04, 2011 02:19PM

Re: Real IP not working?

BigdinoWebmaster December 04, 2011 03:10PM

Re: Real IP not working?

Alexander Kolesen December 05, 2011 01:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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