0

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 127.0.0.1. Also, jetty/GWT has 127.0.0.1 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?

Thanks!

rbrc
  • 103
  • 4

1 Answers1

1

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

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

This should work.

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