简体   繁体   English

在不同路径下访问Tomcat根应用程序(在AWS / Elastic Beanstalk上)

[英]Access Tomcat root application under different path (on AWS/Elastic Beanstalk)

We are deploying a webapp (.war file) from a legacy system where we have full control over our Tomcat instances to Amazon's Elastic Beanstalk instances. 我们正在从遗留系统部署webapp(.war文件),我们可以完全控制我们的Tomcat实例到Amazon的Elastic Beanstalk实例。

On our own systems, we access the web app as a path (eg http://server-name/my-app if we deploy my-app.war), but Elastic Beanstalk renames our war-file to ROOT.war and hence makes the web app available under http://server-name , which breaks our existing applications. 在我们自己的系统上,我们将Web应用程序作为路径访问(例如,如果我们部署my-app.war,则为http://server-name/my-app ),但Elastic Beanstalk将我们的war文件重命名为ROOT.war,因此使Web应用程序在http://server-name下可用,这会破坏我们现有的应用程序。

As per the AWS documentation, we have added a config file under WEB-INF/.ebextensions that copies the following custom context.xml -file to /etc/tomcat7/Catalina/localhost/ROOT.xml : 根据AWS文档,我们在WEB-INF/.ebextensions下添加了一个配置文件,该文件将以下自定义context.xml -file复制到/etc/tomcat7/Catalina/localhost/ROOT.xml

<?xml version='1.0' encoding='utf-8'?>
<Context displayName="localhost" docBase="" path="/my-app">
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>

We have tried different versions of this file, eg omitting docBase, specifying docBase="ROOT" , using the aliases parameter etc., providing the full path to the ROOT directory etc., but none has made our WAR-file accessible under the /my-app path. 我们尝试过这个文件的不同版本,例如省略docBase,指定docBase="ROOT" ,使用aliases参数等,提供ROOT目录等的完整路径,但没有一个使我们的WAR文件可以访问/my-app路径。

Finally, we also tried putting this <Context /> -definition under the <Host /> section in server.xml , but to no avail. 最后,我们还尝试将此<Context /> -definition置于server.xml<Host />部分下,但无济于事。 Any suggestions? 有什么建议么?

Update : when adding the following to server.xml under the <Host/> -definition, I'm able to access my-app under the correct path, but it seems that Tomcat on EB is deploying my application twice now: 更新 :将以下内容添加到<Host/> -definition下的server.xml ,我可以在正确的路径下访问my-app ,但似乎EB上的Tomcat现在正在部署我的应用程序两次:

<Context path="/my-app" docBase="ROOT/"></Context>

Although we can now access our app under the desired path, the application is still deployed twice by Tomcat. 虽然我们现在可以在所需的路径下访问我们的应用程序,但Tomcat仍然会部署该应用程序两次。 While this is a minor nuisance for us, I can imagine this being a problem on more resource-tight machines. 虽然这对我们来说是一个小麻烦,但我可以想象这在资源紧张的机器上是一个问题。 On the plus side, we can now start migrating our apps to no longer use the resource path when accessing the API, which leads to cleaner and shorter API URLs. 从好的方面来说,我们现在可以开始迁移我们的应用程序,以便在访问API时不再使用资源路径,从而实现更清晰,更短的API URL。

I know it's two years late. 我知道已经晚了两年。 But seems like disabling deployOnStartup will do the work. 但似乎禁用deployOnStartup将完成工作。

<Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="false" deployOnStartup="false">

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

相关问题 在AWS Elastic Beanstalk应用程序中运行Tomcat Docker时进行端口转发 - Port forwarding in when running a Tomcat Docker in an AWS Elastic Beanstalk application AWS Elastic Beanstalk-Tomcat Java Spring Boot应用程序出现问题 - AWS Elastic Beanstalk - Problem with tomcat java spring boot application 使用AWS Elastic Beanstalk时编辑应用程序路径 - Edit application path when using AWS Elastic Beanstalk 使用 AWS Elastic Beanstalk 进行应用程序日志记录 - Application logging with AWS Elastic Beanstalk AWS Elastic Beanstalk Tomcat - 高内存使用率 - AWS Elastic Beanstalk Tomcat - high memory usage Elastic Beanstalk Servlet过滤器上的AWS Tomcat - AWS Tomcat on Elastic Beanstalk servlet Filter 如何在 Tomcat AWS Elastic beanstalk (Spring Boot Application) 中修改或添加新的 Nginx 配置 - How to modify or add new Nginx configuration in Tomcat AWS Elastic beanstalk (Spring Boot Application) 如何将 LetsEncrypt SSL 安装到运行 Tomcat 8 和 Java 8 平台的 AWS Elastic Beanstalk 应用程序上 - How do I install LetsEncrypt SSL onto AWS Elastic Beanstalk application running Tomcat 8 with Java 8 Platform 使用 Logback 的 AWS Elastic Beanstalk 应用程序日志记录 - AWS Elastic Beanstalk Application Logging with Logback AWS Elastic Beanstalk:访问系统变量 - AWS Elastic Beanstalk: access System variables
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM