简体   繁体   English

嵌入式Tomcat不会在AWS Elastic Beanstalk中侦听端口80

[英]Embedded Tomcat won't listen to port 80 in AWS Elastic Beanstalk

I'm launching a Spring Boot .jar with Embedded Tomcat to an Elastic Beanstalk (Java) instance. 我正在使用嵌入式Tomcat将Spring Boot .jar发布到Elastic Beanstalk(Java)实例。

server.port=80 in the configuration file, however EB won't let Tomcat bind to port 80. 配置文件中的server.port = 80,但EB不会让Tomcat绑定到端口80。

What's preventing Tomcat from listening to port 80 and how do I fix it? 是什么阻止了Tomcat监听端口80以及如何解决?

Here's the pertinent section of the logs: 这是日志的相关部分:

Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat";  Protocol handler start failed
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:1000) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    ... 21 common frames omitted
Caused by: java.net.SocketException: Permission denied
    at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_121]
    at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_121]
    at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_121]
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_121]
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) ~[na:1.8.0_121]
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:210) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:980) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:573) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    at org.apache.catalina.connector.Connector.startInternal(Connector.java:993) ~[tomcat-embed-core-8.5.11.jar!/:8.5.11]
    ... 22 common frames omitted

2017-02-09 09:05:28.126  INFO 2451 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-02-09 09:05:28.156  INFO 2451 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-02-09 09:05:28.167 ERROR 2451 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The Tomcat connector configured to listen on port 80 failed to start. The port may already be in use or the connector may be misconfigured.

Action:

Verify the connector's configuration, identify and stop any process that's listening on port 80, or configure this application to listen on another port.

2017-02-09 09:05:28.175  INFO 2451 --- [           main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@5387f9e0: startup date [Thu Feb 09 09:05:19 UTC 2017]; root of context hierarchy
2017-02-09 09:05:28.178  INFO 2451 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

I assume topic starter already resolved this problem, but I'll post my solution here for the new people who'll be stuck on the same issue. 我认为主题启动器已经解决了这个问题,但我会在这里发布我的解决方案,以解决那些陷入同一问题的新人。

I've made my Spring Boot application accessible from port 80 on AWS Elastic Beanstalk by setting environment property SERVER_PORT to 5000 (you can set it in "Configuration" > "Software Configuration"). 通过将环境属性SERVER_PORT设置为5000,您可以从AWS Elastic Beanstalk上的端口80访问我的Spring Boot应用程序(您可以在“Configuration”>“Software Configuration”中进行设置)。

Idea taken from here 这里采取的想法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM