如果使用 public ip,为什么 Rundeck 会重定向到 aws 上的 ec2 私有 ip?
Why Rundeck redirect to ec2 private ip on aws if using public ip?
- Public ip 是:
12.34.56.78
(假的).
- 私人ip是:
21.43.65.87
(假的).
- 主机名是
ip-21.43.65.87
(假的)。
访问时:
重定向到:
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)
这可能是由于 public IPv4 addressing in AWS EC2 instances:
"Each instance that receives a public IP address is also given an external DNS hostname; for example, ec2-203-0-113-25.compute-1.amazonaws.com. We resolve an external DNS hostname to the public IP address of the instance outside the network of the instance, and to the private IPv4 address of the instance from within the network of the instance. The public IP address is mapped to the primary private IP address through network address translation (NAT)"
Rundeck 可以侦听的 IP 地址是配置到其网络接口的地址,如 documentation 中所述,但不是通过 NAT 映射的 IP 地址。
此外,您还可以通过在启动 jar 时添加以下 属性 来强制 Rundeck 仅使用 IPv4 套接字: -Djava.net.preferIPv4Stack=true 。
希望对您有所帮助。
在这两个配置文件中编辑 public 个 IP 后,效果很好。
- ~/rundeck/etc/framework.属性
- ~/rundeck/server/config/rundeck-config.属性
- Public ip 是:
12.34.56.78
(假的). - 私人ip是:
21.43.65.87
(假的). - 主机名是
ip-21.43.65.87
(假的)。
访问时:
重定向到:
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)
这可能是由于 public IPv4 addressing in AWS EC2 instances:
"Each instance that receives a public IP address is also given an external DNS hostname; for example, ec2-203-0-113-25.compute-1.amazonaws.com. We resolve an external DNS hostname to the public IP address of the instance outside the network of the instance, and to the private IPv4 address of the instance from within the network of the instance. The public IP address is mapped to the primary private IP address through network address translation (NAT)"
Rundeck 可以侦听的 IP 地址是配置到其网络接口的地址,如 documentation 中所述,但不是通过 NAT 映射的 IP 地址。
此外,您还可以通过在启动 jar 时添加以下 属性 来强制 Rundeck 仅使用 IPv4 套接字: -Djava.net.preferIPv4Stack=true 。
希望对您有所帮助。
在这两个配置文件中编辑 public 个 IP 后,效果很好。
- ~/rundeck/etc/framework.属性
- ~/rundeck/server/config/rundeck-config.属性