早上好!
我有在运行GWT应用程序的docker6前面设置nginx。 我试图转发的IP地址,所有我在网上find的答案告诉我这样做:
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;
这工作得很好,除了jetty的日志不显示X-Real-IP,他们显示127.0.0.1。 另外,jetty / GWT对于getThreadLocalRequest().getRemoteAddr()具有127.0.0.1,但是我可以访问X-Real-IP来获得正确的远程IP。
任何想法如何获得正确的远程ip为jetty日志,也getThreadLocalRequest().getRemoteAddr()正常工作?
谢谢!
您只需将转发的configuration文件添加到/etc/jetty.xml中的连接器即可。 例:
<Call name="addConnector"> <Arg> <New class="org.eclipse.jetty.server.nio.SelectChannelConnector"> <Set name="forwarded">true</Set>
这应该工作。