java - All requests seem to be coming from 127.0.0.1 using Tomcat on Azure -
i using azure's web app service , running tomcat instance. want restrict access manager app ip, simple enough set there 1 issue, according tomcat requests(remote , local) seem coming 127.0.0.1. there way in azure make sure x-forwarded-for header gets set correctly?
due azure load balance, seems azure website instance request 127.0.0.1. can use "x-forwarded-for" ip.
if request contains x-forwarded-for header, first ip in should 1 looking for, "x-forwarded-for" reputed defacto standard, however, if client exists on private network , connects internet via nat gateway, ip of nat server, not client, refer https://en.wikipedia.org/wiki/x-forwarded-for more information x-forwarded-for. please try use following code client ip.
string ip = request.getheader("x-forwarded-for"); if (ip == null) { ip = request.getremoteaddr(); }
you can see test result.
Comments
Post a Comment