Reputation: 10152
I'm using Ruby on Rails as server-side framework, but I'm sure that solution is cross-platform.
I want to show user his real ip address. The application is deployed in corporate network. Most of users connect to application in straightforward way without proxy, NAT and etc. But some of them use proxy.
Now they see IP address of proxy server.
What is the best way to show them their real IP address?
As I could see It is not possible using only serve-side techniques. So solution should be something using JS (almost all users enable JS), Flash (about 80% users use it) or JAVA (about 50%). It would be great if solution was rails plugin, but it is not so important.
UPD. Unfortunately, X-Forwarded-For header has no interesting information.
UPD2. I want to show a local network ip (e.g. 192.168..).
UPD3. Almost all client browsers are Internet Explorer (7,8,6 versions)
Upvotes: 2
Views: 5759
Reputation: 8198
You could use node.js as a websocket server, and on the clientside have a javascript websocket application.
Once connected, you can read the IP out to be accessible by Ruby (via the filesystem api or something else).
Here's a simple error log application that has a good example of a Websocket server using node.js: http://gonzalo123.wordpress.com/2011/05/09/real-time-monitoring-php-applications-with-websockets-and-node-js/
As far as how websockets interact with proxies, a quick search I learned that securing the websocket with SSL will enable you to bypass proxies. (Ref: http://showmetheco.de/articles/2011/2/diving-into-html5-with-websockets-and-perl.html)
While this idea was off the top of my head, I can't do all the research for you but this should get you started to a potential solution.
BTW Websockets are an HTML5 feature, so your corporation may need to have everyone's browsers updated ^^.
Upvotes: 0
Reputation: 1208
Its an interest problem but I'm going to the bearer of bad news. No matter the platform or code you use, you will never get the solution to work 100%.
Let me explain, Some proxyies forward the originator ip in a header (usually x-forwarded-for). This isn't 100%.
Javascript at the client side MAY (pending security restrictions) give you the client ip, however, this could be a local network ip (e.g. 192.168..)
UPD: Please see my comments below for a javascript solution description that would work if all users are on a corporate network.
Upvotes: 2