Hmmm.
I have "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;" in my
nginx conf and apparently no other related directives.
Starting the Mojo server via
MOJO_REVERSE_PROXY=1 carton exec -- morbo script/app
and having these statements in my code:
warn " remote addr: " . $c->tx->remote_address . "\n";
warn "original remote addr: " . $c->tx->original_remote_address . "\n";
warn " x-forwarded-for: " .
$c->tx->req->headers->header('X-Forwarded-For') . "\n";
I get this:
remote addr: 10.1.0.40
original remote addr: 127.0.0.1
x-forwarded-for: 10.1.0.40
The nginx runs on the same host as the mojo app and 10.1.0.40 is my desktop
pc accessing the nginx.
There´s no other proxy between me and the nginx so having only one ip in
"X-Forwarded-For" is what is to be expected.
So everything looks good to me:
$c->tx->remote_address respects the "running behind proxy" setting and
gives me the ip of the client.
$c->tx->original_remote_address gives me the ip from the original (proxy)
request to the Mojolicious server.
If I omit MOJO_REVERSE_PROXY=1 I get:
remote addr: 127.0.0.1
original remote addr: 127.0.0.1
x-forwarded-for: 10.1.0.40
Maybe you misunderstood what "original" in "original_remote_address" means?
It´s not about the client request to the proxy but about the original
request to Mojolicious without Mojolicious helpfully interfering to protect
any code using "remote_address()" from changes by being deployed either
behind a reverse proxy or not.
Best,
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.