Hi Heiko,

Thank you for your response.

I have tried removing the "real_ip_header" and "real_ip_recursive" 
directives from the nginx config as you suggested but nothing changed. I 
have also tried enabling and disabling the "proxy => 1" directive from the 
hypnotoad config which also had no effect. I tried all 4 combinations of 
"real_ip_*" directives added and removed and "proxy => 1" added and removed.

No matter how I changed the nginx config, or the hypnotoad config I always 
get the same results every time which look like this.

$controller->req->headers->header('X-Forwarded-For')  = "[originating IP], 
[proxy IP]"
$controller->req->headers->header('X-Real-Ip')  = "[originating IP]"
$controller->tx->remote_address = "[proxy IP]"
$controller->tx->original_remote_address = "127.0.0.1"

I found it particularly puzzling that the "proxy => 1" config directive had 
no effect. Also, what is the point of the original_remote_address attribute 
if it is always set to localhost?

You were right that I can just use $controller->req->headers->header(
'X-Real-Ip') to get what I want, and I guess this is the best solution I 
have found for now.

I am just really curious about what is going on because I was under the 
impression from other threads and docs that there *IS* a correct 
configuration where $controller->tx->remote_address would contain the 
originating IP in a reverse proxy situation, but I just can't seem to get 
it to work.

Cheers,
Sam


On Friday, February 17, 2017 at 4:20:45 AM UTC+11, Heiko Jansen wrote:
>
> As far as I understand it, this is what happens:
>
> Step 1:
>
> http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_header => 
> "Defines the request header field whose value will be used to replace the 
> client address."
>
> So in your config you tell nginx to treat the value of the header "
> X-Forwarded-For" from the incoming client request as the "real ip".
>
> Step 2:
>
> Then with "proxy_set_header X-Real-IP $remote_addr;" you tell nginx to 
> send the "fake real ip" from "Step 1" as the value of the header "
> X-Real-IP" to your Mojo app.
>
> Unless you have another reverse proxy in front of your nginx I´d say you 
> should simply remove the "real_ip_header" and "real_ip_recursive" 
> directives from your nginx config and everything should work as expected 
> (as long as you tell your Mojo server that it sits behind a reverse proxy).
>
> In any case "$controller->req->headers->header('X-Real-IP')" should now 
> give you the original client IP.
>
> HTH
> - Heiko
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to