[英]AWS Elastic Beanstalk - Problem with tomcat java spring boot application
Do you have any idea what I can't access my application hosted on Amazon Elastic Beanstalk? 您是否知道我无法访问Amazon Elastic Beanstalk上托管的应用程序的内容?
Configuration: Tomcat 8.5 with Java 8 running on 64bit Amazon Linux/3.0.6 My app: Java spring boot application 配置:在64位Amazon Linux / 3.0.6上运行Java 8的Tomcat 8.5我的应用程序:Java spring boot应用程序
On my localhost, everything is working fine. 在我的本地主机上,一切正常。
I've set the server.port = 5000 in my application.properties file. 我在application.properties文件中设置了server.port = 5000。
When i trying to get my app login page using link: 当我尝试使用链接获取我的应用登录页面时:
http://testenv-env.eu-west-1.elasticbeanstalk.com/employee/login http://testenv-env.eu-west-1.elasticbeanstalk.com/employee/login
I received and 404 error: 我收到了404错误消息:
HTTP Status 404 – Not Found Type Status Report HTTP状态404 –找不到类型状态报告
Message /employee/login 消息/员工/登录
but when I add a port to the link: 但是当我向链接添加端口时:
http://testenv-env.eu-west-1.elasticbeanstalk.com:5000/employee/login http://testenv-env.eu-west-1.elasticbeanstalk.com:5000/employee/login
the error is: This site can't be reached. 错误是:无法访问此站点。
My security group configuration: 我的安全组配置:
/var/log/tomcat8/localhost_access_log.txt /var/log/tomcat8/localhost_access_log.txt
127.0.0.1 - - [17/Nov/2018:10:19:04 +0000] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [17/Nov/2018:10:21:16 +0000] "GET /employee/login HTTP/1.1" 404 1092
127.0.0.1 - - [17/Nov/2018:10:29:02 +0000] "GET / HTTP/1.1" 404 1074
127.0.0.1 - - [17/Nov/2018:10:29:56 +0000] "GET /employee/login HTTP/1.1" 404 1092
/var/log/httpd/error_log 在/ var /日志/的httpd / error_log中
[Sat Nov 17 10:19:18.529071 2018] [mpm_worker:notice] [pid 3716:tid 140569196038208] AH00295: caught SIGTERM, shutting down
[Sat Nov 17 10:19:22.241929 2018] [ssl:warn] [pid 25414:tid 140137380542528] AH01873: Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Nov 17 10:19:22.243341 2018] [mpm_worker:notice] [pid 25414:tid 140137380542528] AH00292: Apache/2.4.34 (Amazon) OpenSSL/1.0.2k-fips configured -- resuming normal operations
[Sat Nov 17 10:19:22.243372 2018] [core:notice] [pid 25414:tid 140137380542528] AH00094: Command line: '/usr/sbin/httpd'
and my pom.xml dependencies: 和我的pom.xml依赖项:
<groupId>com.project</groupId>
<artifactId>iam</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>iam</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
First step would be check your URL 第一步是检查您的网址
http://iam-env.eu-west-1.elasticbeanstalk.com/employee/login http://iam-env.eu-west-1.elasticbeanstalk.com/employee/login
itself looks incorrect. 本身看起来不正确。 It is too generic to be right.
这太笼统了,是不对的。 I suggest you look up the AWS Beanstalk All Applications screen.
建议您查找“ AWS Beanstalk所有应用程序”屏幕。 In the box that appears on the right for the correct environment you will find your URL which will be something like this
在正确环境右侧显示的框中,您会找到您的URL,该URL类似于以下内容
https://test-env.asu2mcXXrr.eu-west-2.elasticbeanstalk.com https://test-env.asu2mcXXrr.eu-west-2.elasticbeanstalk.com
@michal9225 what you have to just set is the Routing. @ michal9225您只需要设置“路由”即可。 What happens is beanstalk URL expect that your application is running on Port 80 and while developing an application in our local system we generally change the port as our other application or services may be running on most common ports.
发生的是beantalk URL,它期望您的应用程序在端口80上运行,并且在本地系统中开发应用程序时,我们通常会更改端口,因为其他应用程序或服务可能会在大多数常见端口上运行。
So now you have two options:- 所以现在您有两个选择:
1- set a load balancer and route 5000 port to 80 and then access the application via load balancer URL 1-设置负载均衡器并将5000端口路由到80,然后通过负载均衡器URL访问应用程序
2- change the port from 5000 to 80 from your Application.property file (server.port = 80) 2-将Application.property文件中的端口从5000更改为80(server.port = 80)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.