繁体   English   中英

如何为弹性beanstalk tomcat提供配置

[英]How do I supply configuration to elastic beanstalk tomcat

在本地部署到tomcat时,我将此更改(如下所示)发送到server.xml,有没有办法可以将其提供给Elastic Beanstalk?

<Connector connectionTimeout="20000" port="8080" 
       protocol="org.apache.coyote.http11.Http11NioProtocol" 
       redirectPort="8443"/>'

谢谢 '

您无需提供自定义AMI即可立即执行此操作。 按照以下说明操作: http//aws.typepad.com/aws/2012/10/customize-elastic-beanstalk-using-configuration-files.html

为了在webapp中提供自定义服务器xml create .ebextensions文件夹,请在其中添加自定义server.xml文件并添加一个文件: server-update.config with content:

container_commands:
  replace-config:
  command: cp .ebextensions/server.xml /etc/tomcat7/server.xml

在不替换整个Tomcat server.xml文件的情况下实现此目的的另一种方法是在.ebextensions文件夹中使用以下内容(例如tomcat.config

files:
  "/tmp/update_tomcat_server_xml.sh":
    owner: root
    group: root
    mode: "000755"
    content: |
      #! /bin/bash
      CONFIGURED=`grep -c '<Connector port="8080" URIEncoding="UTF-8"' /etc/tomcat7/server.xml`
      if [ $CONFIGURED = 0 ]
        then
          sed -i 's/Connector port="8080"/Connector port="8080" URIEncoding="UTF-8"/' /etc/tomcat7/server.xml
          logger -t tomcat_conf "/etc/tomcat7/server.xml updated successfully"
          exit 0
        else
          logger -t tomcat_conf "/etc/tomcat7/server.xml already updated"
          exit 0
      fi

container_commands:
  00_update_tomcat_server_xml:
    command: sh /tmp/update_tomcat_server_xml.sh

此配置创建一个脚本( files ),然后运行它( container_command )。 该脚本检查server.xmlUIREncoding="UTF8"字符串,如果找不到,则使用sed命令将其添加。

这个解决方案的好处是,如果你升级你的Tomcat版本(例如从7升级到8),那么你不必担心在各种WAR文件中更新server.xml

此外,此示例用于添加UIREncoding参数,但脚本很容易适应从原始问题添加<Connector ... />'属性。

暂无
暂无

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

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