Sage CRM 7.2 Tomcat Setting for EC2 Amazon Server’s Elastic IP

By | September 26, 2014

Recently we came across a Tomcat issue where Dashboard and Excel Import Export was not working after upgrade from 6.2 to 7.2 on an Amazon Server, every configuration was properly in place but Tomcat logs were showing db connectivity issues. After deep digging on this issue we came to know that Amazon server works on Elastic IP concept.
GUMU Sage CRM Integrations : Sage ERP X3 | Sage 100 | Sage 500 | Sage 300
An Elastic IP address (EIP) is a static IP address designed for dynamic cloud computing. With an EIP, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account. Your EIP is associated with your AWS account, not a particular instance, and it remains associated with your account until you choose to explicitly release it.
On further investigation we have noticed that Dashboards, etc worked when accessing via localhost, but it was getting failed when elastic IP was used.
Root Cause:
This was because the elastic IP is actually a type of proxy – redirected requests to Tomcat which had to be rerouted to respective server to make it working, where the necessary ports weren’t open; while since these EIP’s are dynamic in nature hence CRM URL Rewriter was not able to resolve different IP addresses to actual hosting server.
How we Resolved:
We amended CRM.Rewriter.rules so that redirected requests would always go to localhost.
Example original rule: 
RewriteRule ^/sdata/crmj/(.*)$ http://%{HTTP_HOST}:10009/crmj/$1?%{QUERY_STRING} [P]
Amended rule: 
RewriteRule ^/sdata/crmj/(.*)$ http://localhost:10009/crmj/$1?%{QUERY_STRING} [P]
Since we have hardcoded it to localhost now it does’t matter Tomcat is getting which EIP, it’s URL Rewriter always takes care of it and resolves it to hosting server.
Note* Above mentioned technique might have some implications which however we have not observed till date but to make it working on Amazon EC2 this tweaking worked fine for us. We will update you on our blogs in case we face any anomaly due to this.
Also Read:
1) Apache Tomcat Java configuration issues
2) Error exporting reports to excel in CRM part 2
3) Mailing reports after converting from Crystal Reports to PDF format
4) File to PDF conversion using FOP
5) Export To PDF functionality for Quotes in Sage CRM