Obtain a site visitor's IP?


I’m currently working on a project that users can access as a proxy server from another website; however, I need to be able to rate limit users. Before I spend a bunch of time attempting this, is there even a way to track a visitor’s request data to see if they’ve gone over? Is there a way to block a visitor’s IP if they go over the limit?

Thank you,

The visitor IP address shows in the first of the list in the request header x-forwarded-for

This may be less useful for tracking than you’d expect because

  • VPN may assign different IP on each visit
  • ISP may assign different IP on each visit
  • CGNAT (ISP) may assign same IP across many visitors
  • bots on shared hosting may be assigned the same IP across many bots

A better approach would be to use cookies, which in turn can be blocked by a visitor’s browser.

If you mean Glitch’s container limit, I don’t think this is possible, as Glitch’s limit is imposed before the app receives the request. You could keep count and warn them when the server is close to limits, or impose your own smaller limit per visitor.

Note, there are regulatory requirements in place where you have to tell your visitor if you are tracking them.