when deploying locally to tomcat, I make this change (below) to server.xml, is there a way I can supply this to Elastic Beanstalk?
<Connector connectionTimeout="20000" port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
redirectPort="8443"/>'
thanks '
Saved configurations are stored in the Elastic Beanstalk S3 bucket in a folder named after your application. For example, configurations for an application named my-app in the us-west-2 region for account number 123456789012 can be found at s3://elasticbeanstalk-us-west-2-123456789012/resources/templates/my-app .
Elastic Beanstalk supports nginx (the default) and Apache HTTP Server as the proxy servers on the Tomcat platform. If your Elastic Beanstalk Tomcat environment uses an Amazon Linux AMI platform branch (preceding Amazon Linux 2), you also have the option of using Apache HTTP Server Version 2.2 .
On AWS, open Elastic Beanstalk. Go to your Application > Environment > Configuration > Software Configuration . Under Environment Properties you will find a list of properties you can configure. These variables will be attached to the process.
Another way to implement this without replacing the entire Tomcat server.xml
file is using the following in your .ebextensions
folder (e.g. 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
This config creates a script (files
) and then runs it (container_command
). The script checks the server.xml
for the UIREncoding="UTF8"
string and if it doesn't find it, it then adds it in using the sed
command.
The nice thing about this solution is that if you upgrade your version of Tomcat (e.g. from 7 to 8) then you don't have to worry about updating the server.xml
in your various WAR files.
Also, this example is for adding the UIREncoding
parameter but the script is very easily adapted to add <Connector ... />'
property from the original question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With