Elastic bean stalk entity too large error. how to fix this - java

I am working on a spring boot project and i am trying to add a file into S3 which is working fine in local but when i am doing it on beanstalk server its not working . I researched it and found that we can add .extensions in our file and add some config files but it still does not work for me . i have a file in .ebextensions/01_files.config
i have tried this:-
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
http {
client_max_body_size 2000M;
}
i have tried this
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 2000M;
i have tried this
container_commands:
01_reload_nginx:
command: "service nginx reload"
files:
"/etc/nginx/conf.d/proxy.conf":
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 2000M;
but none of them has work
also i have a file in .ebextensions/nginx/conf.d
which is proxy.conf which contains
client_max_body_size 2000M;
I have application properties which look like this :
# ============ MULTIPART ==================
# Enable multipart uploads
spring.servlet.multipart.enabled=true
# Threshold after which files are written to disk.
spring.servlet.multipart.file-size-threshold=5MB
# Max file size.
spring.servlet.multipart.max-file-size=2000MB
# Max Request Size
spring.servlet.multipart.max-request-size=2000MB
spring.http.multipart.max-file-size=2000MB
spring.http.multipart.max-request-size=2000MB
upload_max_filesize=2000M
post_max_size=2000M

but none of them has work also
A likely reason is that you are using current version of EB environment which runs Amazon Linux 2 (AL2). However, the nginx file you are attempting to modify (/etc/nginx/conf.d/proxy.conf) is only for Amazon Linux 1 (AL1).
For AL2, nginx config files should be in .platform, not in .ebextensions as explained and exemplified in the AWS docs for AL2:
Reverse proxy configuration for AL2
You can try the following:
.platform/nginx/conf.d/myconf.conf with content of
http {
client_max_body_size 2000M;
}

Related

ActiveMQ data and conf folder needs to be changed to different file system in Linux

I have downloaded and setup ActiveMQ 5.15.0 in my machine and followed this guide.
In conf folder I see in conf/log4j.properties there is a line with the path for Log Location.
log4j.appender.logfile.file=${activemq.data}/activemq.log
How this variable ${activemq.data} is configured and how to change it?
The value for ${activemq.data} is read from the environment variable $ACTIVEMQ_DATA by the activemq script when starting the broker. For example, when you start the broker using the default configuration you'll see this logged:
$ ./activemq console
...
ACTIVEMQ_HOME: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_BASE: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_CONF: /home/jbertram/java/apache-activemq-5.15.8/conf
ACTIVEMQ_DATA: /home/jbertram/java/apache-activemq-5.15.8/data
Loading message broker from: xbean:activemq.xml
...
However, if you set the $ACTIVEMQ_DATA variable to something else, e.g.:
$ export ACTIVEMQ_DATA=/tmp
Then this will be logged:
$ ./activemq console
...
ACTIVEMQ_HOME: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_BASE: /home/jbertram/java/apache-activemq-5.15.8
ACTIVEMQ_CONF: /home/jbertram/java/apache-activemq-5.15.8/conf
ACTIVEMQ_DATA: /tmp
Loading message broker from: xbean:activemq.xml
...
You can also change this using the bin/env file. This is what the default env contains:
...
# Active MQ installation dirs
# ACTIVEMQ_HOME="<Installationdir>/"
# ACTIVEMQ_BASE="$ACTIVEMQ_HOME"
# ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf"
# ACTIVEMQ_DATA="$ACTIVEMQ_BASE/data"
# ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp"
...
You could change this to be something like this:
...
# Active MQ installation dirs
# ACTIVEMQ_HOME="<Installationdir>/"
# ACTIVEMQ_BASE="$ACTIVEMQ_HOME"
# ACTIVEMQ_CONF="$ACTIVEMQ_BASE/conf"
ACTIVEMQ_DATA="/tmp"
# ACTIVEMQ_TMP="$ACTIVEMQ_BASE/tmp"
...
It's worth noting that ActiveMQ "Classic" 5.15.0 was released in June of 2017 (i.e. over 5 years ago now). I strongly recommend you upgrade to a more recent release, ideally the latest.

AWS Elastic Beanstalk .ebextensions not updating the default configuration

I have a memory disk issue in my Elastic Beanstalk instance due to the log rotation so I am trying to modify the default configuration for log rotation by following the documentation:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html
After adding my config and rebuilding the environment, I can see my config (in the path which I specified) when I connect via SSH to my EB. However, it looks like my changes are not applied and logs don't rotate according to my config.
##################################################################
## Sets up the elastic beanstalk log publication to include
## the admin logs for cloudwatch logs
##################################################################
Resources:
AWSEBAutoScalingGroup:
Metadata:
"AWS::CloudFormation::Init":
configSets:
"_OnInstanceBoot":
"CmpFn::Insert":
values:
- EBCWLLogPublicationSetup
EBCWLLogPublicationSetup:
files:
"/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.awslogs.conf":
content: |
/var/log/awslogs.log {
size 2M
rotate 3
missingok
compress
notifempty
copytruncate
dateext
dateformat %s
olddir /var/log/rotated
}
mode: "000644"
My EB instance contains a Java application (dropwizard, Java 1.8) which is dockerized.
Any idea?
Finally, I could find a different approach which works:
container_commands:
01-custom-rotate:
command: "/bin/sed -i 's/size 10M/size 7M/g' /etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.awslogs.conf"
Basically it replaces a text in the config file. The EB still needs to be rebuilt to see the changes.

Protocol handler start failed Spring Boot SSL application

As soon as I add the SSL properties in spring boot my application does not run from command line.
Here is my properties file
#API Settings
server.port = 1180
## MULTIPART (MultipartProperties)
# Enable multipart uploads
spring.servlet.multipart.enabled=true
# Threshold after which files are written to disk.
spring.servlet.multipart.file-size-threshold=2KB
# Max file size.
spring.servlet.multipart.max-file-size=200MB
# Max Request Size
spring.servlet.multipart.max-request-size=215MB
## File Storage Properties
# All files uploaded through the REST API will be stored in this directory
file.upload-dir=D:/uploads
server.ssl.enabled=true
#Client
server.ssl.client-auth=need
server.ssl.key-store=D:\Symbox Staging Setup\SimulationAPI2waySLL\JKS\nt-ms.jks
server.ssl.key-store-password=kalsym
server.ssl.key-alias=nt-ms
server.ssl.key-store-type=JKS
server.ssl.trust-store=D:\Symbox Staging Setup\SimulationAPI2waySLL\JKS\nt-ms.jks
server.ssl.trust-store-password=kalsym
Here is my output
If anyone is still looking for solution, this stackoverflow.com/a/58602917/8719655 works. Thanks Carlos

ElasticBeanstalk - Changing java.security?

I would like to change the securerandom.source value in $JAVA_HOME/jre/lib/security/java.security on my Elastic Beanstalk instance.
How can I do that through the .ebextensions? Or is the another way to do that?
At the beginning of $JAVA_HOME/jre/lib/security/java.security file, there's a paragraph saying
# This is the "master security properties file".
#
# An alternate java.security properties file may be specified
# from the command line via the system property
#
# -Djava.security.properties=<URL>
#
# This properties file appends to the master security properties file.
# If both properties files specify values for the same key, the value
# from the command-line properties file is selected, as it is the last
# one loaded.
So you may create a java-security.config file with the following content under .ebextensions folder:
# Create a file named java-security under /usr/share/tomcat8/conf to override the default value of securerandom.source
files:
"/usr/share/tomcat8/conf/java-security" :
mode: "000755"
owner: tomcat
group: tomcat
content: |
securerandom.source=<the file you want for securerandom.source>
Then go to elastic beanstalk environment
-> Configuration
-> Software
-> Environment properties
-> type java.security.properties for Name, and /usr/share/tomcat8/conf/java-security for Value.
Then restart the tomcat. Your securerandom.source should be changed to the value you wish.
One thing to remember is that the user tomcat must have permissions to read /usr/share/tomcat8/conf/java-security file.

How do I supply configuration to elastic beanstalk tomcat

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
'
You can do it now without providing custom AMI. Follow instructions in: http://aws.typepad.com/aws/2012/10/customize-elastic-beanstalk-using-configuration-files.html
In order to provide custom server xml create .ebextensions folder in webapp, put there custom server.xml file and add one more file: server-update.config with content:
container_commands:
replace-config:
command: cp .ebextensions/server.xml /etc/tomcat7/server.xml
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.

Categories

Resources