【发布时间】:2019-09-25 14:17:29
【问题描述】:
我知道,这里有很多这样的问题和答案,但没有一个对我有帮助。我尝试在 AWS Elastic Beanstalk 上安装我的简单 Spring Boot 应用程序。有一个限制:它必须使用.jsp 模板,所以它是.war,而不是.jar。如果我在 Elastic Beanstalk 上使用预定义的 Tomcat 环境,一切正常,但我的目标是使用 Java 环境。
当我安装我的应用程序时,它的状态是Degraded,当我尝试访问该 url 时我变成了 502。
本地一切都很完美。
我将application.properties 中的端口更改为5000,但没有帮助。我找到了一个建议,为 TCP Port 5000 "0.0.0.0/32" 使用入站安全规则,但它没有帮助。
这是我的pom.xml 依赖项:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>4.6.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
application.properties:
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
server.port=5000
Java 主类:
@SpringBootApplication
public class DemowebApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemowebApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(DemowebApplication.class, args);
}
}
AWS 错误日志:
2019/05/07 21:04:45 [error] 7827#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 91.232.158.8, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5000/", host: "my-endpoint-tst.us-east-2.elasticbeanstalk.com"
2019/05/07 21:04:46 [error] 7827#0: *19 connect() failed (111: Connection refused) while connecting to upstream, client: 91.232.158.8, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:5000/favicon.ico", host: "my-endpoint-tst.us-east-2.elasticbeanstalk.com", referrer: "my-endpoint-tst.us-east-2.elasticbeanstalk.com/"
我怀疑问题出在我的 Tomcat 配置上,但我对它的所有实验都没有帮助。
【问题讨论】:
-
这可能是您的安全组的问题。请打开端口 5000 的入站规则。
-
是的,我看到了该建议并做到了,但 id 没有帮助:
Custom TCP Rule TCP 5000 0.0.0.0/32 -
能否请您选择 HTTP 80 0.0.0.0/0 和 ::/0 并尝试一下。
-
它没有帮助(
标签: java amazon-web-services spring-boot tomcat amazon-elastic-beanstalk