我已经尝试了几天,在aws ec2上创建一个记录不完整的游戏应用程序(帮助朋友)作为一个完整的游戏和bash-rookie并最终设法启动它;但是没有像在声明的playShop.sh文件中那样监听端口8080,而是在随机端口(8081)上,因为8080抛出了“已经在使用中” - 异常。
playShop.sh(更改端口):
sudo nohup ./start -Dconfig.file = / home / ec2-user / prod.conf -Dhttp.port = 8081 -Dhttp.address = 127.0.0.1&
启动
!/ usr / bin / env sh
exec java $ * -cp“
dirname $0
/ lib / *”play.core.server.NettyServerdirname $0
到目前为止一切顺利!但是我现在如何通过网络浏览器访问它?当我呼叫公共DNS时,我会遇到一个标准的欢迎页面。我尝试在该端口上设置安全组设置(quicklaunch1 - > inbound),并且还使用负载均衡器 - >听众,但没有任何帮助。
这似乎是漫长旅程的最后一步,任何帮助都是如此受欢迎! 谢谢。
编辑: 这就是nohup.out在这两个端口上记录的内容:
Play server process ID is 1593
[[37minfo[0m] play - Application started (Prod)
Oops, cannot start the server.
org.jboss.netty.channel.ChannelException: Failed to bind to: /127.0.0.1:8080
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:298)
at play.core.server.NettyServer.<init>(NettyServer.scala:63)
at play.core.server.NettyServer$.createServer(NettyServer.scala:132)
at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:162)
at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:161)
at scala.Option.map(Option.scala:133)
at play.core.server.NettyServer$.main(NettyServer.scala:161)
at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind(Native Method)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:137)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:77)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:138)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:90)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:64)
at org.jboss.netty.channel.Channels.bind(Channels.java:569)
at org.jboss.netty.channel.AbstractChannel.bind(AbstractChannel.java:187)
at org.jboss.netty.bootstrap.ServerBootstrap$Binder.channelOpen(ServerBootstrap.java:343)
at org.jboss.netty.channel.Channels.fireChannelOpen(Channels.java:170)
at org.jboss.netty.channel.socket.nio.NioServerSocketChannel.<init>(NioServerSocketChannel.java:80)
at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:158)
at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:86)
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:277)
... 7 more
Play server process ID is 1650
[[37minfo[0m] play - Application started (Prod)
[[37minfo[0m] play - Listening for HTTP on port 8081..
答案 0 :(得分:0)
到目前为止一切顺利!但是我现在如何通过网络浏览器访问它? 当我呼叫公共DNS时,我会遇到一个标准的欢迎页面。我试过了 在该端口上设置安全组设置(quicklaunch1 - &gt; inbound) 并且还使用负载均衡器 - >听众,但没有真正的 帮助
当您使用网络浏览器点击域名时,它会默认尝试连接到端口80.要解决此问题,您必须像以下一样访问它:
http://myserver.com:8081/
用户很难。为了解决这个问题,推荐的路由是让代理服务器处理来自客户端的标准请求,这些客户端监听端口80并根据需要将请求转发给应用服务器(播放服务器)。我通常建议使用nginx,播放框架主页有一个basic guide for setting it up。在你的情况下,它将是这样的:
http {
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
upstream my-backend {
server 127.0.0.1:8081;
}
server {
server_name www.mysite.com mysite.com;
rewrite ^(.*) https://www.mysite.com$1 permanent;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/ssl/certs/my_ssl.crt;
ssl_certificate_key /etc/ssl/private/my_ssl.key;
keepalive_timeout 70;
server_name www.mysite.com;
location / {
proxy_pass http://my-backend;
}
}
}