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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -