BROWSER IP ADDRESS

Started by suriakumar, February 16, 2021, 01:05:25 AM

Previous topic - Next topic

suriakumar

Sir,

I want to get the browser's IP Address.  The Global variable %REMOTE_IP$ does not work.  It contains server's ip address.  It does not contain Browser's IP Address.   Please inform me how to get the Browser's IP address through PXPLUS

michaelgreer

In every application I have build using the webserver %remote_ip$ is always the browser/remote ip address.  In fact, I have used that as part of a "firewall" scheme to lock down access.

Mike King

#2
Is it possible that you have a proxy forwarder on your site? 

Basically the %REMOTE_IP$ is the IP address at the other end of the connection which normally is the browser, but if your request are being routed through a proxy server, load balancer, VPN, or similar it will reflect the address of the server doing the redirection.

In most cases these servers will insert the true originating IP address in the request header thus in one of the global variables we provide.  Typically, although not a 100% approved standard, the originating IP address will be found in %X_Forwarded_For$ which comes from the X-Forwarded-For request header.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

suriakumar

#3
Sir,

In Which VERSION of pxplus you have the global variable %X_FORWARDED_FOR$ ?. I am using PXPLUS version 11.65.   This variable is not available in this Version.    The WEB SERVER Version is 1.3.17.  Or In case if you have introduced in your latest version of web server please inform me the WEB SERVER Version

J.SURIAKUMAR

Mike King

When the PxPlus web server runs your application it converts all HTTP request headers into global variables.

If %X_Forwarded_For$ is not set then there was no X-Forwarded-for: header in the HTTP request.  There may however be a %Forwarded$ header.

Here are some details on this header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For

It is also quite possible that your server may not provide the original workstations IP address.  This is not uncommon as the IP address provides a means to help identify the user which may or may not be desirable.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

mike motz

when debugging web issues use a line like,  FLOUT=%FLOUT; IF FLOUT<>0 THEN DUMP (FLOUT)*
after you opened the file and set %FLOUT to the channel number of the file you just created.
my dump has it as twice ... REMOTE_ADDR=76.68.62.122 and %remote_ip$="76.68.62.122"
You'll see any variable that is available in memory.

martinp

OMG Mike King to the rescue years later... Thank you for this..

So I am using an Nginx Reverse Proxy to have multiple web servers on one server, and of course $REMOTE_IP$ was giving the IP of the Proxy server.

After googling I found my way here, I used DUMP(%PRINT_FN) To see all the variables Mike was talking about and sure enough there it was:

%HTTP_X_REAL_IP$  which was exactly what I needed thank you

It also had

%HTTP_X_FORWARDED_FOR$

But they had %HTTP as a prefix.

Maybe this is what the documentation was referring to with:
%http_extraheaders

Maybe this could be clarified in the online document.

Anyway just wanted to give an update on this.  Thanks

Mike King

Glad this helped your resolve your issue.

If you look at NGINX documentation it will describe the headers that may get added.  In particular the X-Real-ip header which is described at https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com