<div dir="ltr"><div><br></div><div class="gmail_extra"><div class="gmail_quote">On Thu, May 7, 2015 at 12:07 PM, Dewangga Bachrul Alam <span dir="ltr"><<a href="mailto:dewanggaba@xtremenitro.org" target="_blank">dewanggaba@xtremenitro.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello!<br>
<span class=""><br>
On 05/07/2015 09:45 AM, Nurahmadie Nurahmadie wrote:<br>
> Hi<br>
><br>
> On Thu, May 7, 2015 at 11:38 AM, Dewangga Bachrul Alam<br>
</span><div><div class="h5">> <<a href="mailto:dewanggaba@xtremenitro.org">dewanggaba@xtremenitro.org</a> <mailto:<a href="mailto:dewanggaba@xtremenitro.org">dewanggaba@xtremenitro.org</a>>> wrote:<br>
><br>
> Hello!<br>
><br>
> Did anyone have same problem when configuring reverse proxy nginx +<br>
> apache, when the request came from nginx, the IP didn't shows real<br>
> visitor.<br>
><br>
> Example access.log:<br>
> 127.0.0.1 - - [07/May/2015:09:27:30 +0700] "GET / HTTP/1.0" 200 61925<br>
> 127.0.0.1 - - [07/May/2015:09:27:35 +0700] "GET / HTTP/1.0" 200 61925<br>
> 127.0.0.1 - - [07/May/2015:09:27:43 +0700] "GET / HTTP/1.0" 200 62367<br>
><br>
> My proxy config:<br>
> proxy_redirect off;<br>
> proxy_set_header Host $host;<br>
> proxy_set_header X-Real-IP $remote_addr;<br>
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>
> proxy_set_header X-Forwarded-Proto https;<br>
> client_body_buffer_size 128k;<br>
> proxy_connect_timeout 90;<br>
> proxy_send_timeout 90;<br>
> proxy_read_timeout 90;<br>
> proxy_buffers 32 4k;<br>
><br>
> In centos6, I got additional packages like mod_rpaf /<br>
> mod_extract_forwarded. But I didn't find any similiar packages on<br>
> centos7.<br>
><br>
> Any hints?<br>
><br>
><br>
> You don't have to use both X-Real-IP and X-Forwarded-For. Just put the<br>
> one which actually used by the app.<br>
><br>
<br>
</div></div>I just test using $_SERVER['REMOTE_ADDR']; and its only shows 127.0.0.1.<br></blockquote><div><br></div>The remote_addr will always shows 127.0.0.1 since apache is requested by nginx, which also binds on 127.0.0.1, not directly by users. <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Anyway, it's should be fine to use them both (CMIIW). But I've tried it<br>
and nothing changes, the visitors ips are not showed on apache logs.<br>
<br>
For additional information, I set the apache listen only to<br>
<a href="http://127.0.0.1:8080" target="_blank">127.0.0.1:8080</a> and set the proxy pass to <a href="http://127.0.0.1:8080" target="_blank">http://127.0.0.1:8080</a>;<br>
<span class=""><br>
> And it's safer to also use $remote_addr for X-Forwarded-For rather<br>
> than $proxy_add_x_forwarded_for, since that header can be manipulated by<br>
> the client.<br>
><br>
> For the log, check your log format at apache, it probably logging<br>
> remote_addr (or something like that, not sure what they call it at<br>
> apache) rather than the IP specified by X-Forwarded-For or X-Real-IP.<br>
> Change it accordingly.<br>
><br>
><br>
<br>
</span>Didn't know yet, you have any hints? :)<br></blockquote><div> </div><div>As I stated before, you want to change your log format to shows ip from either X-Forwarded-For or X-Real-IP </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
_______________________________________________<br>
<div class=""><div class="h5">nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">regards,<br>Nurahmadie<br>--<br></div>
</div></div>