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!

1 Answer 1

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .