Hello I move my Dancer app from wpsgi to " starman + apache proxy" in my code, I registered client ip address with my $ip = request->remote_address(); now, Ip address is always 127.0.0.1 see my apache config <VirtualHost *:80> ServerName admin.web.com DocumentRoot /home/web/ HostnameLookups Off UseCanonicalName Off ProxyPreserveHost On ProxyPass bootstrap ! ProxyPass fontawesome ! ProxyPass images ! ProxyPass javascripts ! ProxyPass css ! ProxyPass / http://localhost:5002/ retry=0 Keepalive=on ProxyPassReverse / http://localhost:5002/ TimeOut 300 <Proxy *> Order allow,deny Allow from all </Proxy> </VirtualHost> how I can get client Ip adress from my Dancer code ? thanks Hugues.
On 22/04/15 09:45, Hugues wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
I generally use: my $ip = request->headers->{'x-forwarded-for'} || request->address(); (Dancer 1, though, don't know if it works in Dancer2) Regards, Hermen -- "I urge you to please notice when you are happy, and exclaim or murmur or think at some point, 'If this isn't nice, I don't know what is.'" -- Kurt Vonnegut
yes but request->headers->{'x-forwarded-for'} can be address client, adresse proxy1, adresse proxy2 etc... | x-forwarded-for":"65.28.225.84, 54.240.144.193" | Le 22/04/2015 10:06, Hermen Lesscher a écrit :
On 22/04/15 09:45, Hugues wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
I generally use:
my $ip = request->headers->{'x-forwarded-for'} || request->address();
(Dancer 1, though, don't know if it works in Dancer2)
Regards, Hermen
On 04/23/2015 09:34 AM, Hugues wrote:
yes but request->headers->{'x-forwarded-for'} can be
address client, adresse proxy1, adresse proxy2 etc... | x-forwarded-for":"65.28.225.84, 54.240.144.193"
That's why it is better to use the Plack middleware :-). Regards Racke
| Le 22/04/2015 10:06, Hermen Lesscher a écrit :
On 22/04/15 09:45, Hugues wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
I generally use:
my $ip = request->headers->{'x-forwarded-for'} || request->address();
(Dancer 1, though, don't know if it works in Dancer2)
Regards, Hermen
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- Modern Perl, Dancer and eCommerce consulting.
On 04/23/2015 09:36 AM, Stefan Hornburg (Racke) wrote:
On 04/23/2015 09:34 AM, Hugues wrote:
yes but request->headers->{'x-forwarded-for'} can be
address client, adresse proxy1, adresse proxy2 etc... | x-forwarded-for":"65.28.225.84, 54.240.144.193"
That's why it is better to use the Plack middleware :-).
Regards Racke
Alternatively one can use mod_rpaf [0] for apache to set the necessary headers. This code works for me together with mod_rpaf: my $ip = request->forwarded_for_address || request->remote_address; Regards, Alex [0] https://github.com/gnif/mod_rpaf
On Thu, Apr 23, 2015 at 12:45 AM, Alex Mestiashvili <alex@biotec.tu-dresden.de> wrote:
Alternatively one can use mod_rpaf [0] for apache to set the necessary headers. This code works for me together with mod_rpaf:
my $ip = request->forwarded_for_address || request->remote_address;
I thought with mod_rpaf, you could just use request->remote_address. And that mod_rpaf is needed on the proxied server, not the proxy server, which is not apache in this case.
On 04/23/2015 04:02 PM, Yitzchak Scott-Thoennes wrote:
On Thu, Apr 23, 2015 at 12:45 AM, Alex Mestiashvili <alex@biotec.tu-dresden.de> wrote:
Alternatively one can use mod_rpaf [0] for apache to set the necessary headers. This code works for me together with mod_rpaf:
my $ip = request->forwarded_for_address || request->remote_address; I thought with mod_rpaf, you could just use request->remote_address. And that mod_rpaf is needed on the proxied server, not the proxy server, which is not apache in this case.
Yes, that's correct. mod_rpaf is for the backend "apache" server. Now I reread the thread again and see that backend is starman..., sorry. Just in my configuration the backend is apache and dancer works via fcgi dispatcher. Regards, Alex
request->header('x-forwarded-for'); On Wed, Apr 22, 2015 at 8:45 AM, Hugues <hugues@max4mail.com> wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
see my apache config
<VirtualHost *:80> ServerName admin.web.com DocumentRoot /home/web/ HostnameLookups Off UseCanonicalName Off ProxyPreserveHost On
ProxyPass bootstrap ! ProxyPass fontawesome ! ProxyPass images ! ProxyPass javascripts ! ProxyPass css ! ProxyPass / http://localhost:5002/ retry=0 Keepalive=on ProxyPassReverse / http://localhost:5002/ TimeOut 300 <Proxy *> Order allow,deny Allow from all </Proxy> </VirtualHost>
how I can get client Ip adress from my Dancer code ? thanks Hugues.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
I don't use Apache as a reverse proxy so please test with "x-forward-for" and "x-real-ip" With Dancer1 you could use something like this: hook 'before' => sub { if ( request->header('x-real-ip') ) { var ipaddress => request->header('x-real-ip'); } else { var ipaddress => request->address; } } On Wed, Apr 22, 2015 at 11:08 AM, Paulo A Ferreira < paulo.a.ferreira@gmail.com> wrote:
request->header('x-forwarded-for');
On Wed, Apr 22, 2015 at 8:45 AM, Hugues <hugues@max4mail.com> wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
see my apache config
<VirtualHost *:80> ServerName admin.web.com DocumentRoot /home/web/ HostnameLookups Off UseCanonicalName Off ProxyPreserveHost On
ProxyPass bootstrap ! ProxyPass fontawesome ! ProxyPass images ! ProxyPass javascripts ! ProxyPass css ! ProxyPass / http://localhost:5002/ retry=0 Keepalive=on ProxyPassReverse / http://localhost:5002/ TimeOut 300 <Proxy *> Order allow,deny Allow from all </Proxy> </VirtualHost>
how I can get client Ip adress from my Dancer code ? thanks Hugues.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On 04/22/2015 09:45 AM, Hugues wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
see my apache config
<VirtualHost *:80> ServerName admin.web.com DocumentRoot /home/web/ HostnameLookups Off UseCanonicalName Off ProxyPreserveHost On
ProxyPass bootstrap ! ProxyPass fontawesome ! ProxyPass images ! ProxyPass javascripts ! ProxyPass css ! ProxyPass / http://localhost:5002/ retry=0 Keepalive=on ProxyPassReverse / http://localhost:5002/ TimeOut 300 <Proxy *> Order allow,deny Allow from all </Proxy> </VirtualHost>
how I can get client Ip adress from my Dancer code ? thanks Hugues.
Did you set behind_proxy in configuration? Regards Racke -- Modern Perl, Dancer and eCommerce consulting.
Thanks Paulo and Stefan I change my code to: my $ip; if ( request->remote_address() eq "127.0.0.1" ) { $ip = request->header('x-forwarded-for'); } else { $ip = request->remote_address(); } debug "My ip : ". $ip; it's ok now [110804] debug @0.260742> [hit #34]My ip : 192.168.0.19 in /home/git/ I try with and without behind_proxy: true I don't see difference thanks Hugues Le 22/04/2015 12:15, Stefan Hornburg (Racke) a écrit :
On 04/22/2015 09:45 AM, Hugues wrote:
Hello I move my Dancer app from wpsgi to " starman + apache proxy"
in my code, I registered client ip address with
my $ip = request->remote_address();
now, Ip address is always 127.0.0.1
see my apache config
<VirtualHost *:80> ServerName admin.web.com DocumentRoot /home/web/ HostnameLookups Off UseCanonicalName Off ProxyPreserveHost On
ProxyPass bootstrap ! ProxyPass fontawesome ! ProxyPass images ! ProxyPass javascripts ! ProxyPass css ! ProxyPass / http://localhost:5002/ retry=0 Keepalive=on ProxyPassReverse / http://localhost:5002/ TimeOut 300 <Proxy *> Order allow,deny Allow from all </Proxy> </VirtualHost>
how I can get client Ip adress from my Dancer code ? thanks Hugues. Did you set behind_proxy in configuration?
Regards Racke
Hugues <hugues@max4mail.com> writes:
Thanks Paulo and Stefan
I change my code to:
my $ip;
if ( request->remote_address() eq "127.0.0.1" ) { $ip = request->header('x-forwarded-for'); } else { $ip = request->remote_address(); }
debug "My ip : ". $ip;
it's ok now
Try to load Plack::Middleware::ReverseProxy, which should do the trick. -- Marco
On Wed, Apr 22, 2015 at 4:01 AM, Hugues <hugues@max4mail.com> wrote:
if ( request->remote_address() eq "127.0.0.1" ) { $ip = request->header('x-forwarded-for'); } else { $ip = request->remote_address(); }
debug "My ip : ". $ip;
it's ok now
[110804] debug @0.260742> [hit #34]My ip : 192.168.0.19 in /home/git/
No, if the request to your apache already had an x-forwarded-for, you will have multiple comma-separated ips.
I try with and without
behind_proxy: true
I don't see difference
Looks from the doc like that does something different.
Ok, thanks, I do not see this point. In this cas this code must be acceptable ? my $ip; if ( request->remote_address() eq "127.0.0.1" ) { my @list_ip = split(",", request->header('x-forwarded-for') ); $ip = $list_ip[0]; } else { $ip = request->remote_address(); } bye Hugues Le 22/04/2015 18:34, Yitzchak Scott-Thoennes a écrit :
On Wed, Apr 22, 2015 at 4:01 AM, Hugues <hugues@max4mail.com> wrote:
if ( request->remote_address() eq "127.0.0.1" ) { $ip = request->header('x-forwarded-for'); } else { $ip = request->remote_address(); }
debug "My ip : ". $ip;
it's ok now
[110804] debug @0.260742> [hit #34]My ip : 192.168.0.19 in /home/git/
No, if the request to your apache already had an x-forwarded-for, you will have multiple comma-separated ips.
I try with and without
behind_proxy: true
I don't see difference Looks from the doc like that does something different.
dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On 04/22/2015 01:50 PM, WK wrote:
2015-04-22 13:15 GMT+03:00 Stefan Hornburg (Racke) <racke@linuxia.de>:
Did you set behind_proxy in configuration?
I did not found such configuration option in docs. What you mean?
https://metacpan.org/pod/Dancer::Config#behind_proxy-boolean Regards Racke -- Modern Perl, Dancer and eCommerce consulting.
participants (8)
-
Alex Mestiashvili -
Hermen Lesscher -
Hugues -
Marco Pessotto -
Paulo A Ferreira -
Stefan Hornburg (Racke) -
WK -
Yitzchak Scott-Thoennes