如果使用公共IP,为什么Rundeck会重定向到aws上的ec2私有ip?

时间:2018-06-08 02:47:32

标签: java amazon-web-services ip host rundeck

  • 公共IP是:12.34.56.78(假)。
  • 私人IP是:21.43.65.87(假)。
  • 主机名为ip-21.43.65.87(假)。

访问时:

http://12.34.56.78:4440

重定向到:

http://ip-21-34-65-87:4440/menu/home

official document开始,有一条通知:

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)

2 个答案:

答案 0 :(得分:1)

这可能是由于公开IPv4 addressing in AWS EC2 instances

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

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

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

希望它有所帮助。

答案 1 :(得分:0)

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

  • 〜/ rundeck的/ etc / framework.properties
  • 〜/ rundeck /服务器/配置/ rundeck-config.properties