Good morning!

I have nginx setup in front of jetty 6, which is running a GWT application. I am trying to forward the ip address, and all the answers I find on the internet tell me to do this:

proxy_pass http://localhost:8080;
proxy_set_header X-Real-IP  $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

This works just fine, except that jetty's logs don't show the X-Real-IP, they show Also, jetty/GWT has for getThreadLocalRequest().getRemoteAddr(), although I can access the X-Real-IP to get the correct remote IP.

Any ideas how to get the correct remote ip for the jetty logs and also get getThreadLocalRequest().getRemoteAddr() to work correctly?


up vote 1 down vote accepted

You should just add forwarded config to your connector in /etc/jetty.xml. Example:

<Call name="addConnector">
        <New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
           <Set name="forwarded">true</Set>

This should work.

  • In todays version of jetty by doing this I'm getting: java.lang.ClassNotFoundException: org.eclipse.jetty.server.nio.SelectChannelConnector – Alpha2k Feb 26 at 20:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.