Java 如果使用公共ip,为什么Rundeck重定向到aws上的ec2私有ip? 公共ip为:12.34.56.78(假) 私有ip为:21.43.65.87(假) 主机名是ip-21.43.65.87(假)

Java 如果使用公共ip,为什么Rundeck重定向到aws上的ec2私有ip? 公共ip为:12.34.56.78(假) 私有ip为:21.43.65.87(假) 主机名是ip-21.43.65.87(假),java,amazon-web-services,ip,host,rundeck,Java,Amazon Web Services,Ip,Host,Rundeck,访问时: 重定向到: 从中,有一个通知: server.http.host Address/hostname to listen on, default is all addresses "0.0.0.0" 因此,我尝试使用该选项启动rundeck: java -XX:MaxPermSize=256m -Xmx1024m -jar -Dserver.http.host="12.34.56.78" rundeck-launcher-2.0.0.jar 上面说我不能用那个地址。为什么? 编

访问时:

重定向到:

从中,有一个通知:

server.http.host Address/hostname to listen on, default is all addresses "0.0.0.0"
因此,我尝试使用该选项启动rundeck:

java -XX:MaxPermSize=256m -Xmx1024m -jar -Dserver.http.host="12.34.56.78" rundeck-launcher-2.0.0.jar
上面说我不能用那个地址。为什么?


编辑 运行启动命令后:

        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at com.dtolabs.rundeck.RunServer.run(RunServer.java:128)
        at com.dtolabs.rundeck.RunServer.main(RunServer.java:81)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.dtolabs.rundeck.ExpandRunServer.invokeMain(ExpandRunServer.java:758)
        at com.dtolabs.rundeck.ExpandRunServer.execute(ExpandRunServer.java:715)
        at com.dtolabs.rundeck.ExpandRunServer.run(ExpandRunServer.java:313)
        at com.dtolabs.rundeck.ExpandRunServer.main(ExpandRunServer.java:117)
2018-06-08 03:53:11.824:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.server.Server@6fc26fb1: java.net.BindException: Cannot assign requested address
java.net.BindException: Cannot assign requested address
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:264)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.server.Server.doStart(Server.java:303)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at com.dtolabs.rundeck.RunServer.run(RunServer.java:128)
        at com.dtolabs.rundeck.RunServer.main(RunServer.java:81)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.dtolabs.rundeck.ExpandRunServer.invokeMain(ExpandRunServer.java:758)
        at com.dtolabs.rundeck.ExpandRunServer.execute(ExpandRunServer.java:715)
        at com.dtolabs.rundeck.ExpandRunServer.run(ExpandRunServer.java:313)
        at com.dtolabs.rundeck.ExpandRunServer.main(ExpandRunServer.java:117)
java.net.BindException: Cannot assign requested address
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Net.java:433)
        at sun.nio.ch.Net.bind(Net.java:425)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:264)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.server.Server.doStart(Server.java:303)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at com.dtolabs.rundeck.RunServer.run(RunServer.java:128)
        at com.dtolabs.rundeck.RunServer.main(RunServer.java:81)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.dtolabs.rundeck.ExpandRunServer.invokeMain(ExpandRunServer.java:758)
        at com.dtolabs.rundeck.ExpandRunServer.execute(ExpandRunServer.java:715)
        at com.dtolabs.rundeck.ExpandRunServer.run(ExpandRunServer.java:313)
        at com.dtolabs.rundeck.ExpandRunServer.main(ExpandRunServer.java:117)
这可能是由于:

“每个接收公共IP地址的实例也会获得一个外部DNS主机名;例如,ec2-203-0-113-25.compute-1.amazonaws.com。我们将外部DNS主机名解析为实例网络外部实例的公共IP地址,并从实例网络内部解析为实例的专用IPv4地址。公共IP地址通过网络地址转换(NAT)映射到主私有IP地址”

Rundeck可以侦听的IP地址是配置为其网络接口的地址,如中所述,但不是通过NAT映射的IP地址

此外,还可以通过在启动jar时添加以下属性,强制Rundeck仅使用IPv4套接字:-Djava.net.preferIPv4Stack=true


希望有帮助。

在这两个配置文件中编辑公共IP后,效果很好

  • ~/rundeck/etc/framework.properties
  • ~/rundeck/server/config/rundeck-config.properties

你可以发布一个合适的stacktrace吗?@ScaryWombat为此添加了跟踪。非常感谢。但即使我添加了
-Djava.net.preferIPv4Stack=true
,也得到了相同的结果。来自
http://12.34.56.78:4440
重定向到
http://ip-21-34-65-87:4440/menu/home